* @since 1.17
*/
abstract class DatabaseUpdater {
- protected static $updateCounter = 0;
-
/**
* Array of updates to perform on the database
*
* @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