X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Finstaller%2FDatabaseUpdater.php;h=aece3170f075f818e24511c4805f67a199c697d8;hb=30f4b3c103997bd9154b247cda8282eb8bd0ba66;hp=0e4b098aebc40892cd6789007ddd056c0f943874;hpb=c223ccb7eebdfd1ec944f86f0627fa1662a7c66a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index 0e4b098aeb..aece3170f0 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -20,6 +20,7 @@ * @file * @ingroup Deployment */ +use MediaWiki\MediaWikiServices; require_once __DIR__ . '/../../maintenance/Maintenance.php'; @@ -56,7 +57,7 @@ abstract class DatabaseUpdater { /** * Handle to the database subclass * - * @var DatabaseBase + * @var Database */ protected $db; @@ -100,11 +101,11 @@ abstract class DatabaseUpdater { /** * Constructor * - * @param DatabaseBase $db To perform updates on + * @param Database $db To perform updates on * @param bool $shared Whether to perform updates on shared tables * @param Maintenance $maintenance Maintenance object which created us */ - protected function __construct( DatabaseBase &$db, $shared, Maintenance $maintenance = null ) { + protected function __construct( Database &$db, $shared, Maintenance $maintenance = null ) { $this->db = $db; $this->db->setFlag( DBO_DDLMODE ); // For Oracle's handling of schema files $this->shared = $shared; @@ -170,14 +171,14 @@ abstract class DatabaseUpdater { } /** - * @param DatabaseBase $db + * @param Database $db * @param bool $shared * @param Maintenance $maintenance * * @throws MWException * @return DatabaseUpdater */ - public static function newForDB( &$db, $shared = false, $maintenance = null ) { + public static function newForDB( Database $db, $shared = false, $maintenance = null ) { $type = $db->getType(); if ( in_array( $type, Installer::getDBTypes() ) ) { $class = ucfirst( $type ) . 'Updater'; @@ -191,7 +192,7 @@ abstract class DatabaseUpdater { /** * Get a database connection to run updates * - * @return DatabaseBase + * @return Database */ public function getDB() { return $this->db; @@ -402,6 +403,20 @@ abstract class DatabaseUpdater { } } + /** + * Get appropriate schema variables in the current database connection. + * + * This should be called after any request data has been imported, but before + * any write operations to the database. The result should be passed to the DB + * setSchemaVars() method. + * + * @return array + * @since 1.28 + */ + public function getSchemaVars() { + return []; // DB-type specific + } + /** * Do all the updates * @@ -410,6 +425,8 @@ abstract class DatabaseUpdater { public function doUpdates( $what = [ 'core', 'extensions', 'stats' ] ) { global $wgVersion; + $this->db->setSchemaVars( $this->getSchemaVars() ); + $what = array_flip( $what ); $this->skipSchema = isset( $what['noschema'] ) || $this->fileHandle !== null; if ( isset( $what['core'] ) ) { @@ -440,6 +457,8 @@ abstract class DatabaseUpdater { * @param bool $passSelf Whether to pass this object we calling external functions */ private function runUpdates( array $updates, $passSelf ) { + $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); + $updatesDone = []; $updatesSkipped = []; foreach ( $updates as $params ) { @@ -454,7 +473,7 @@ abstract class DatabaseUpdater { flush(); if ( $ret !== false ) { $updatesDone[] = $origParams; - wfGetLBFactory()->waitForReplication(); + $lbFactory->waitForReplication(); } else { $updatesSkipped[] = [ $func, $params, $origParams ]; }