'ListDefinedTags': When trying to find all defined tags.
&$tags: The list of tags.
-'LoadExtensionSchemaUpdates': called by maintenance/updaters.inc when upgrading
-database schema
+'LoadExtensionSchemaUpdates': called during database installation and updates
+&updater: A DatabaseUpdater subclass
'LocalFile::getHistory': called before file history query performed
$file: the file
'MysqlInstaller' => 'includes/installer/MysqlInstaller.php',
'MysqlUpdater' => 'includes/installer/MysqlUpdater.php',
'PostgresInstaller' => 'includes/installer/PostgresInstaller.php',
+ 'PostgresUpdater' => 'includes/installer/PostgresUpdater.php',
'SqliteInstaller' => 'includes/installer/SqliteInstaller.php',
'SqliteUpdater' => 'includes/installer/SqliteUpdater.php',
'OracleInstaller' => 'includes/installer/OracleInstaller.php',
$this->settings[$var] = $GLOBALS[$var];
}
- foreach ( $this->dbTypes as $type ) {
+ foreach ( self::getDBTypes() as $type ) {
$installer = $this->getDBInstaller( $type );
if ( !$installer->isCompiled() ) {
}
public static function newForDB( $db, $shared ) {
- switch( $db->getType() ) {
- case 'mysql':
- case 'sqlite':
- case 'oracle':
- $class = ucfirst( $db->getType() ) . 'Updater';
- return new $class( $db, $shared );
- default:
- throw new MWException( __METHOD__ . ' called for unsupported $wgDBtype' );
+ $type = $db->getType();
+ if( in_array( $type, Installer::getDBTypes() ) ) {
+ $class = ucfirst( $type ) . 'Updater';
+ return new $class( $db, $shared );
+ } else {
+ throw new MWException( __METHOD__ . ' called for unsupported $wgDBtype' );
}
}
+ public function getDB() { return $this->db; }
+
public function doUpdates() {
global $IP, $wgVersion;
require_once( "$IP/maintenance/updaters.inc" );
*
* @var array
*/
- protected $dbTypes = array(
+ protected static $dbTypes = array(
'mysql',
'postgres',
'sqlite',
/**
* Get a list of known DB types.
*/
- public function getDBTypes() {
- return $this->dbTypes;
+ public static function getDBTypes() {
+ return self::$dbTypes;
}
/**
$goodNames = array();
$allNames = array();
- foreach ( $this->dbTypes as $name ) {
+ foreach ( self::getDBTypes() as $name ) {
$db = $this->getDBInstaller( $name );
$readableName = wfMsg( 'config-type-' . $name );
--- /dev/null
+<?php
+
+/**
+ * Class for handling updates to Postgres databases.
+ *
+ * @TODO @FIXME - Postgres should use sequential updates like Mysql, Sqlite
+ * and everybody else. It never got refactored like it should've. For now,
+ * just wrap the old do_postgres_updates() in this class so we can clean up
+ * the higher-level stuff.
+ *
+ * @ingroup Deployment
+ * @since 1.17
+ */
+
+class PostgresUpdater extends Updater {
+ protected function getCoreUpdateList() {
+ return array();
+ }
+
+ public function doUpdates() {
+ do_postgres_updates();
+ }
+}
function do_all_updates( $shared = false, $purge = true ) {
global $wgSharedDB, $wgSharedTables, $wgDatabase, $wgDBtype;
- wfRunHooks( 'LoadExtensionSchemaUpdates' );
+ $updater = DatabaseUpdater::newForDb( $wgDatabase, $shared );
+
+ wfRunHooks( 'LoadExtensionSchemaUpdates', array( &$updater ) );
+
+ $updater->doUpdates();
if ( $wgDBtype === 'postgres' ) {
- do_postgres_updates();
return;
}
- $up = DatabaseUpdater::newForDb( $wgDatabase, $shared );
- $up->doUpdates();
-
wfOut( "Deleting old default messages (this may take a long time!)..." );
if ( !defined( 'MW_NO_SETUP' ) ) {
define( 'MW_NO_SETUP', true );