* 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
This commit is contained in:
parent
dde8c46712
commit
47296df668
7 changed files with 73 additions and 9 deletions
|
|
@ -123,11 +123,10 @@ abstract class DatabaseInstaller {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform database upgrades
|
* Perform database upgrades
|
||||||
* @todo make abstract
|
*
|
||||||
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
/*abstract*/ function doUpgrade() {
|
public abstract function doUpgrade();
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow DB installers a chance to make last-minute changes before installation
|
* Allow DB installers a chance to make last-minute changes before installation
|
||||||
|
|
@ -138,6 +137,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.
|
* Get an array of MW configuration globals that will be configured by this class.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -301,6 +301,8 @@ The account you specify here must already exist.',
|
||||||
|
|
||||||
'''MyISAM''' may be faster in single-user or read-only installations.
|
'''MyISAM''' may be faster in single-user or read-only installations.
|
||||||
MyISAM databases tend to get corrupted more often than InnoDB databases.",
|
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-charset' => 'Database character set:',
|
||||||
'config-mysql-binary' => 'Binary',
|
'config-mysql-binary' => 'Binary',
|
||||||
'config-mysql-utf8' => 'UTF-8',
|
'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.
|
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].",
|
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' => '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-help' => "This will appear in the title bar of the browser and in various other places.",
|
||||||
'config-site-name-blank' => 'Enter a site name.',
|
'config-site-name-blank' => 'Enter a site name.',
|
||||||
|
|
|
||||||
|
|
@ -130,13 +130,14 @@ class MysqlInstaller extends DatabaseInstaller {
|
||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function doUpgrade() {
|
public function preUpgrade() {
|
||||||
$status = $this->getConnection();
|
$status = $this->getConnection();
|
||||||
if ( !$status->isOK() ) {
|
if ( !$status->isOK() ) {
|
||||||
$this->parent->showStatusError( $status );
|
$this->parent->showStatusError( $status );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$conn = $status->value;
|
$conn = $status->value;
|
||||||
|
$conn->selectDB( $this->getVar( 'wgDBname' ) );
|
||||||
|
|
||||||
# Determine existing default character set
|
# Determine existing default character set
|
||||||
if ( $conn->tableExists( "revision" ) ) {
|
if ( $conn->tableExists( "revision" ) ) {
|
||||||
|
|
@ -164,9 +165,53 @@ class MysqlInstaller extends DatabaseInstaller {
|
||||||
$existingEngine = $row->Type;
|
$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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -115,5 +115,9 @@ class OracleInstaller extends DatabaseInstaller {
|
||||||
"# Oracle specific settings
|
"# Oracle specific settings
|
||||||
\$wgDBprefix = \"{$prefix}\";";
|
\$wgDBprefix = \"{$prefix}\";";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function doUpgrade() {
|
||||||
|
// TODO
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -149,4 +149,9 @@ class PostgresInstaller extends DatabaseInstaller {
|
||||||
\$wgDBmwschema = \"{$schema}\";
|
\$wgDBmwschema = \"{$schema}\";
|
||||||
\$wgDBts2schema = \"{$ts2}\";";
|
\$wgDBts2schema = \"{$ts2}\";";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function doUpgrade() {
|
||||||
|
// TODO
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -210,5 +210,4 @@ class SqliteInstaller extends DatabaseInstaller {
|
||||||
"# SQLite-specific settings
|
"# SQLite-specific settings
|
||||||
\$wgSQLiteDataDir = \"{$dir}\";";
|
\$wgSQLiteDataDir = \"{$dir}\";";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -293,6 +293,7 @@ class WebInstaller_Upgrade extends WebInstallerPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $this->parent->request->wasPosted() ) {
|
if ( $this->parent->request->wasPosted() ) {
|
||||||
|
$installer->preUpgrade();
|
||||||
$this->addHTML(
|
$this->addHTML(
|
||||||
'<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' .
|
'<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>' .
|
'<script>jQuery( "#config-spinner" )[0].style.display = "block";</script>' .
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue