$this->db->begin( __METHOD__ );
$error = $this->db->sourceFile(
- call_user_func( [ $this->db, $sourceFileMethod ] )
+ call_user_func( [ $this, $sourceFileMethod ], $this->db )
);
if ( $error !== true ) {
$this->db->reportQueryError( $error, 0, '', __METHOD__ );
return $this->stepApplySourceFile( 'getUpdateKeysPath', 'updates', false );
}
+ /**
+ * Return a path to the DBMS-specific SQL file if it exists,
+ * otherwise default SQL file
+ *
+ * @param IDatabase $db
+ * @param string $filename
+ * @return string
+ */
+ private function getSqlFilePath( $db, $filename ) {
+ global $IP;
+
+ $dbmsSpecificFilePath = "$IP/maintenance/" . $db->getType() . "/$filename";
+ if ( file_exists( $dbmsSpecificFilePath ) ) {
+ return $dbmsSpecificFilePath;
+ } else {
+ return "$IP/maintenance/$filename";
+ }
+ }
+
+ /**
+ * Return a path to the DBMS-specific schema file,
+ * otherwise default to tables.sql
+ *
+ * @param IDatabase $db
+ * @return string
+ */
+ public function getSchemaPath( $db ) {
+ return $this->getSqlFilePath( $db, 'tables.sql' );
+ }
+
+ /**
+ * Return a path to the DBMS-specific update key file,
+ * otherwise default to update-keys.sql
+ *
+ * @param IDatabase $db
+ * @return string
+ */
+ public function getUpdateKeysPath( $db ) {
+ return $this->getSqlFilePath( $db, 'update-keys.sql' );
+ }
+
/**
* Create the tables for each extension the user enabled
* @return Status
if ( !$status->isOK() ) {
throw new MWException( __METHOD__ . ': unexpected DB connection error' );
}
- LBFactory::setInstance( new LBFactorySingle( [
- 'connection' => $status->value ] ) );
+
+ \MediaWiki\MediaWikiServices::resetGlobalInstance();
+ $services = \MediaWiki\MediaWikiServices::getInstance();
+
+ $connection = $status->value;
+ $services->redefineService( 'DBLoadBalancerFactory', function() use ( $connection ) {
+ return LBFactorySingle::newFromConnection( $connection );
+ } );
+
}
/**