diff options
author | Alexandre Emsenhuber <ialex@users.mediawiki.org> | 2010-08-22 10:37:27 +0000 |
---|---|---|
committer | Alexandre Emsenhuber <ialex@users.mediawiki.org> | 2010-08-22 10:37:27 +0000 |
commit | 47296df668c0e384b59822d0e6e9fc108aa0c99c (patch) | |
tree | 6bc07f178da05ac9e63206acccf1f69dc0b5f3a3 /includes/installer | |
parent | dde8c467124b390f428550ac16db0badd54b0959 (diff) | |
download | mediawikicore-47296df668c0e384b59822d0e6e9fc108aa0c99c.tar.gz mediawikicore-47296df668c0e384b59822d0e6e9fc108aa0c99c.zip |
* Make the MySQL updater work in the new installer
* DatabaseInstaller::doUpgrade() is now abstract
TODO: MysqlUpdater::doUpgrade() is horrible, please someone fix it once it could be
Notes
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/71430
Diffstat (limited to 'includes/installer')
-rw-r--r-- | includes/installer/DatabaseInstaller.php | 14 | ||||
-rw-r--r-- | includes/installer/Installer.i18n.php | 4 | ||||
-rw-r--r-- | includes/installer/MysqlInstaller.php | 51 | ||||
-rw-r--r-- | includes/installer/OracleInstaller.php | 6 | ||||
-rw-r--r-- | includes/installer/PostgresInstaller.php | 5 | ||||
-rw-r--r-- | includes/installer/SqliteInstaller.php | 1 | ||||
-rw-r--r-- | includes/installer/WebInstallerPage.php | 1 |
7 files changed, 73 insertions, 9 deletions
diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php index c7e27198f67b..d9241e529b93 100644 --- a/includes/installer/DatabaseInstaller.php +++ b/includes/installer/DatabaseInstaller.php @@ -123,11 +123,10 @@ abstract class DatabaseInstaller { /** * Perform database upgrades - * @todo make abstract + * + * @return Boolean */ - /*abstract*/ function doUpgrade() { - return false; - } + public abstract function doUpgrade(); /** * Allow DB installers a chance to make last-minute changes before installation @@ -139,6 +138,13 @@ abstract class DatabaseInstaller { } /** + * Allow DB installers a chance to make checks before upgrade. + */ + public function preUpgrade() { + + } + + /** * Get an array of MW configuration globals that will be configured by this class. */ public function getGlobalNames() { diff --git a/includes/installer/Installer.i18n.php b/includes/installer/Installer.i18n.php index 9a54c1ad5b08..f1af5143757a 100644 --- a/includes/installer/Installer.i18n.php +++ b/includes/installer/Installer.i18n.php @@ -301,6 +301,8 @@ The account you specify here must already exist.', '''MyISAM''' may be faster in single-user or read-only installations. MyISAM databases tend to get corrupted more often than InnoDB databases.", + 'config-mysql-egine-mismatch' => "'''Warning:''' you requested the $1 storage engine, but the existing database uses the $2 engine. +This upgrade script can't convert it, so it will remain $2.", 'config-mysql-charset' => 'Database character set:', 'config-mysql-binary' => 'Binary', 'config-mysql-utf8' => 'UTF-8', @@ -308,6 +310,8 @@ MyISAM databases tend to get corrupted more often than InnoDB databases.", This is more efficient than MySQL's UTF-8 mode, and allows you to use the full range of Unicode characters. In '''UTF-8 mode''', MySQL will know what character set your data is in, and can present and convert it appropriately, but it will not let you store characters above the [http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes Basic Multilingual Plane].", + 'config-mysql-charset-mismatch' => "'''Warning:''' you requested the $1 schema, but the existing database has the $2 schema. + This upgrade script can't convert it, so it will remain $2.", 'config-site-name' => 'Name of wiki:', 'config-site-name-help' => "This will appear in the title bar of the browser and in various other places.", 'config-site-name-blank' => 'Enter a site name.', diff --git a/includes/installer/MysqlInstaller.php b/includes/installer/MysqlInstaller.php index 44dfa00b020e..6a3f2f1a1e90 100644 --- a/includes/installer/MysqlInstaller.php +++ b/includes/installer/MysqlInstaller.php @@ -130,13 +130,14 @@ class MysqlInstaller extends DatabaseInstaller { return $status; } - public function doUpgrade() { + public function preUpgrade() { $status = $this->getConnection(); if ( !$status->isOK() ) { $this->parent->showStatusError( $status ); return; } $conn = $status->value; + $conn->selectDB( $this->getVar( 'wgDBname' ) ); # Determine existing default character set if ( $conn->tableExists( "revision" ) ) { @@ -164,9 +165,53 @@ class MysqlInstaller extends DatabaseInstaller { $existingEngine = $row->Type; } } + } else { + $existingSchema = false; + $existingEngine = false; } - - // TODO + + if ( $existingSchema && $existingSchema != $this->getVar( '_MysqlCharset' ) ) { + $this->parent->showMessage( 'config-mysql-charset-mismatch', $this->getVar( '_MysqlCharset' ), $existingSchema ); + $this->setVar( '_MysqlCharset', $existingSchema ); + } + if ( $existingEngine && $existingEngine != $this->getVar( '_MysqlEngine' ) ) { + $this->parent->showMessage( 'config-mysql-egine-mismatch', $this->getVar( '_MysqlEngine' ), $existingEngine ); + $this->setVar( '_MysqlEngine', $existingEngine ); + } + } + + /** + * @todo FIXME: this code is just pure crap for compatibility between + * old and new code. + */ + public function doUpgrade() { + global $wgDatabase, $wgDBuser, $wgDBpassword; + + # Some maintenance scripts like wfGetDB() + LBFactory::enableBackend(); + # For do_all_updates() + $wgDatabase = $this->db; + # Normal user and password are selected after this step, so for now + # just copy these two + $wgDBuser = $this->getVar( '_InstallUser' ); + $wgDBpassword = $this->getVar( '_InstallPassword' ); + + $ret = true; + + ob_start( array( __CLASS__, 'outputHandler' ) ); + try { + do_all_updates( false, true ); + } catch ( MWException $e ) { + echo "\nAn error occured:\n"; + echo $e->getText(); + $ret = false; + } + ob_end_flush(); + return $ret; + } + + public static function outputHandler( $string ) { + return htmlspecialchars( $string ); } /** diff --git a/includes/installer/OracleInstaller.php b/includes/installer/OracleInstaller.php index 0abc69f146a8..f6057f57a529 100644 --- a/includes/installer/OracleInstaller.php +++ b/includes/installer/OracleInstaller.php @@ -115,5 +115,9 @@ class OracleInstaller extends DatabaseInstaller { "# Oracle specific settings \$wgDBprefix = \"{$prefix}\";"; } - + + public function doUpgrade() { + // TODO + return false; + } }
\ No newline at end of file diff --git a/includes/installer/PostgresInstaller.php b/includes/installer/PostgresInstaller.php index f2e5c7611700..c5af5bbe93c3 100644 --- a/includes/installer/PostgresInstaller.php +++ b/includes/installer/PostgresInstaller.php @@ -149,4 +149,9 @@ class PostgresInstaller extends DatabaseInstaller { \$wgDBmwschema = \"{$schema}\"; \$wgDBts2schema = \"{$ts2}\";"; } + + public function doUpgrade() { + // TODO + return false; + } } diff --git a/includes/installer/SqliteInstaller.php b/includes/installer/SqliteInstaller.php index 36301c42ee61..e4b7526330fe 100644 --- a/includes/installer/SqliteInstaller.php +++ b/includes/installer/SqliteInstaller.php @@ -210,5 +210,4 @@ class SqliteInstaller extends DatabaseInstaller { "# SQLite-specific settings \$wgSQLiteDataDir = \"{$dir}\";"; } - }
\ No newline at end of file diff --git a/includes/installer/WebInstallerPage.php b/includes/installer/WebInstallerPage.php index 1e4e1ea5e7d1..644ba7d178de 100644 --- a/includes/installer/WebInstallerPage.php +++ b/includes/installer/WebInstallerPage.php @@ -293,6 +293,7 @@ class WebInstaller_Upgrade extends WebInstallerPage { } if ( $this->parent->request->wasPosted() ) { + $installer->preUpgrade(); $this->addHTML( '<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' . '<script>jQuery( "#config-spinner" )[0].style.display = "block";</script>' . |