X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Finstaller%2FDatabaseUpdater.php;h=6a8a99ff092c232edafcdf765e9f9bfbf4cfcfda;hb=11cdbc02482f7b9de42184f02f1484dc1ff48cbd;hp=fbdc9342ade1adac93b3f80476900aef18aa3e44;hpb=5335a84c9ef221d03f264834cf136d9dd11a749a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index fbdc9342ad..6a8a99ff09 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -32,8 +32,6 @@ require_once __DIR__ . '/../../maintenance/Maintenance.php'; * @since 1.17 */ abstract class DatabaseUpdater { - protected static $updateCounter = 0; - /** * Array of updates to perform on the database * @@ -57,7 +55,7 @@ abstract class DatabaseUpdater { /** * Handle to the database subclass * - * @var DatabaseBase + * @var Database */ protected $db; @@ -77,6 +75,7 @@ abstract class DatabaseUpdater { PopulateBacklinkNamespace::class, FixDefaultJsonContentPages::class, CleanupEmptyCategories::class, + AddRFCAndPMIDInterwiki::class, ]; /** @@ -192,7 +191,7 @@ abstract class DatabaseUpdater { /** * Get a database connection to run updates * - * @return DatabaseBase + * @return Database */ public function getDB() { return $this->db; @@ -221,12 +220,11 @@ abstract class DatabaseUpdater { * * @since 1.17 * - * @param array $update The update to run. Format is the following: - * first item is the callback function, it also can be a - * simple string with the name of a function in this class, - * following elements are parameters to the function. - * Note that callback functions will receive this object as - * first parameter. + * @param array $update The update to run. Format is [ $callback, $params... ] + * $callback is the method to call; either a DatabaseUpdater method name or a callable. + * Must be serializable (ie. no anonymous functions allowed). The rest of the parameters + * (if any) will be passed to the callback. The first parameter passed to the callback + * is always this object. */ public function addExtensionUpdate( array $update ) { $this->extensionUpdates[] = $update; @@ -423,8 +421,6 @@ abstract class DatabaseUpdater { * @param array $what What updates to perform */ public function doUpdates( $what = [ 'core', 'extensions', 'stats' ] ) { - global $wgVersion; - $this->db->setSchemaVars( $this->getSchemaVars() ); $what = array_flip( $what ); @@ -441,12 +437,9 @@ abstract class DatabaseUpdater { $this->checkStats(); } - $this->setAppliedUpdates( $wgVersion, $this->updates ); - if ( $this->fileHandle ) { $this->skipSchema = false; $this->writeSchemaUpdateFile(); - $this->setAppliedUpdates( "$wgVersion-schema", $this->updatesSkipped ); } } @@ -482,23 +475,6 @@ abstract class DatabaseUpdater { $this->updates = array_merge( $this->updates, $updatesDone ); } - /** - * @param string $version - * @param array $updates - */ - protected function setAppliedUpdates( $version, $updates = [] ) { - $this->db->clearFlag( DBO_DDLMODE ); - if ( !$this->canUseNewUpdatelog() ) { - return; - } - $key = "updatelist-$version-" . time() . self::$updateCounter; - self::$updateCounter++; - $this->db->insert( 'updatelog', - [ 'ul_key' => $key, 'ul_value' => serialize( $updates ) ], - __METHOD__ ); - $this->db->setFlag( DBO_DDLMODE ); - } - /** * Helper function: check if the given key is present in the updatelog table. * Obviously, only use this for updates that occur after the updatelog table was @@ -633,7 +609,11 @@ abstract class DatabaseUpdater { * @param string $filename File name to open */ public function copyFile( $filename ) { - $this->db->sourceFile( $filename, false, false, false, + $this->db->sourceFile( + $filename, + null, + null, + __METHOD__, [ $this, 'appendLine' ] ); }