http://www.mediawiki.org/wiki/Special:Code/MediaWiki/69108
Revision: 69108 Author: avar Date: 2010-07-06 20:40:05 +0000 (Tue, 06 Jul 2010) Log Message: ----------- new-installer: Delay database object construction until ->execute time My method of putting code that alters $this->parent->installSteps in the MySQL constructor didn't work because the installer will construct objects for all the databases, even those it doesn't use. This ostensibly happens because it needs to be able to provide defaults for all of them on the DBConnect page. But when I was going to fix that by exiting the MySQL constructior by checking $wgDBtype I found that it didn't work, because WebInstaller calls Installer's __construct *before* any sessions are read or set up, so $wgDBtype will always be mysql, since that's the default. Fix that by delaying the construction of the database objects. The WebInstaller (or equivalent) now has to call ->setupDatabaseObjects() in its ->execute method. This way the defaults on the DBConnect will still be provided, but we'll have access to session data in the database constructors. Ughed-by: Chad <innocentkil...@gmail.com> Modified Paths: -------------- trunk/phase3/includes/installer/Installer.php trunk/phase3/includes/installer/MysqlInstaller.php trunk/phase3/includes/installer/WebInstaller.php Modified: trunk/phase3/includes/installer/Installer.php =================================================================== --- trunk/phase3/includes/installer/Installer.php 2010-07-06 19:37:33 UTC (rev 69107) +++ trunk/phase3/includes/installer/Installer.php 2010-07-06 20:40:05 UTC (rev 69108) @@ -233,6 +233,18 @@ foreach ( $this->defaultVarNames as $var ) { $this->settings[$var] = $GLOBALS[$var]; } + + $this->parserTitle = Title::newFromText( 'Installer' ); + $this->parserOptions = new ParserOptions; + $this->parserOptions->setEditSection( false ); + } + + /* + * Set up our database objects. They need to inject some of their + * own configuration into our global context. Usually this'll just be + * things like the default $wgDBname. + */ + function setupDatabaseObjects() { foreach ( $this->dbTypes as $type ) { $installer = $this->getDBInstaller( $type ); if ( !$installer->isCompiled() ) { @@ -247,10 +259,6 @@ } } } - - $this->parserTitle = Title::newFromText( 'Installer' ); - $this->parserOptions = new ParserOptions; - $this->parserOptions->setEditSection( false ); } /** Modified: trunk/phase3/includes/installer/MysqlInstaller.php =================================================================== --- trunk/phase3/includes/installer/MysqlInstaller.php 2010-07-06 19:37:33 UTC (rev 69107) +++ trunk/phase3/includes/installer/MysqlInstaller.php 2010-07-06 20:40:05 UTC (rev 69108) @@ -35,6 +35,10 @@ function __construct( $parent ) { parent::__construct( $parent ); + if ( $this->parent->getVar( 'wgDBtype' ) !== $this->getName() ) { + return; + } + # Add our user callback to installSteps, right before the tables are created. $where_tables = array_search( "tables", $this->parent->installSteps ); $callback = array( Modified: trunk/phase3/includes/installer/WebInstaller.php =================================================================== --- trunk/phase3/includes/installer/WebInstaller.php 2010-07-06 19:37:33 UTC (rev 69107) +++ trunk/phase3/includes/installer/WebInstaller.php 2010-07-06 20:40:05 UTC (rev 69108) @@ -81,6 +81,10 @@ if ( isset( $session['settings'] ) ) { $this->settings = $session['settings'] + $this->settings; } + + /* Must be called after the session setup above */ + $this->setupDatabaseObjects(); + $this->exportVars(); $this->setupLanguage(); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs