/**
* 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
}
+ /**
+ * 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.
*/
'''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',
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.',
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" ) ) {
$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 );
}
/**
"# Oracle specific settings
\$wgDBprefix = \"{$prefix}\";";
}
-
+
+ public function doUpgrade() {
+ // TODO
+ return false;
+ }
}
\ No newline at end of file
\$wgDBmwschema = \"{$schema}\";
\$wgDBts2schema = \"{$ts2}\";";
}
+
+ public function doUpgrade() {
+ // TODO
+ return false;
+ }
}
"# SQLite-specific settings
\$wgSQLiteDataDir = \"{$dir}\";";
}
-
}
\ No newline at end of file
}
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>' .