* @since 1.17
*/
abstract class DatabaseUpdater {
- protected static $updateCounter = 0;
-
/**
* Array of updates to perform on the database
*
/**
* Handle to the database subclass
*
- * @var DatabaseBase
+ * @var Database
*/
protected $db;
PopulateBacklinkNamespace::class,
FixDefaultJsonContentPages::class,
CleanupEmptyCategories::class,
+ AddRFCAndPMIDInterwiki::class,
];
/**
/**
* Get a database connection to run updates
*
- * @return DatabaseBase
+ * @return Database
*/
public function getDB() {
return $this->db;
*
* @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;
* @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 );
$this->checkStats();
}
- $this->setAppliedUpdates( $wgVersion, $this->updates );
-
if ( $this->fileHandle ) {
$this->skipSchema = false;
$this->writeSchemaUpdateFile();
- $this->setAppliedUpdates( "$wgVersion-schema", $this->updatesSkipped );
}
}
$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
* @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' ]
);
}