/**
* The database connection.
*
- * @var DatabaseBase
+ * @var Database
*/
public $db = null;
*
* @param string $sourceFileMethod
* @param string $stepName
- * @param string $archiveTableMustNotExist
+ * @param bool $archiveTableMustNotExist
* @return Status
*/
private function stepApplySourceFile(
$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
$connection = $status->value;
$services->redefineService( 'DBLoadBalancerFactory', function() use ( $connection ) {
- return new LBFactorySingle( [
- 'connection' => $connection ] );
+ return LBFactorySingle::newFromConnection( $connection );
} );
-
}
/**
$up = DatabaseUpdater::newForDB( $this->db );
try {
$up->doUpdates();
- } catch ( Exception $e ) {
+ } catch ( MWException $e ) {
echo "\nAn error occurred:\n";
echo $e->getText();
$ret = false;
+ } catch ( Exception $e ) {
+ echo "\nAn error occurred:\n";
+ echo $e->getMessage();
+ $ret = false;
}
$up->purgeCache();
ob_end_flush();