* @param array $params Parameters passed from DatabaseBase::factory()
*/
function __construct( array $params ) {
- global $wgDBprefix, $wgDBmwschema;
-
- $this->srvCache = ObjectCache::getLocalServerInstance( 'hash' );
-
$server = $params['host'];
$user = $params['user'];
$password = $params['password'];
$dbName = $params['dbname'];
$flags = $params['flags'];
- $tablePrefix = $params['tablePrefix'];
- $schema = $params['schema'];
- $foreign = $params['foreign'];
+
+ $this->mSchema = $params['schema'];
+ $this->mTablePrefix = $params['tablePrefix'];
$this->cliMode = isset( $params['cliMode'] )
? $params['cliMode']
$this->mSessionVars = $params['variables'];
- /** Get the default table prefix*/
- if ( $tablePrefix === 'get from global' ) {
- $this->mTablePrefix = $wgDBprefix;
- } else {
- $this->mTablePrefix = $tablePrefix;
- }
+ $this->mForeign = $params['foreign'];
- /** Get the database schema*/
- if ( $schema === 'get from global' ) {
- $this->mSchema = $wgDBmwschema;
- } else {
- $this->mSchema = $schema;
- }
-
- $this->mForeign = $foreign;
+ $this->srvCache = isset( $params['srvCache'] )
+ ? $params['srvCache']
+ : new EmptyBagOStuff();
$this->profiler = isset( $params['profiler'] )
? $params['profiler']
$p['dbname'] = isset( $p['dbname'] ) ? $p['dbname'] : false;
$p['flags'] = isset( $p['flags'] ) ? $p['flags'] : 0;
$p['variables'] = isset( $p['variables'] ) ? $p['variables'] : [];
- $p['tablePrefix'] = isset( $p['tablePrefix'] ) ? $p['tablePrefix'] : 'get from global';
+ $p['tablePrefix'] = isset( $p['tablePrefix'] ) ? $p['tablePrefix'] : '';
if ( !isset( $p['schema'] ) ) {
$p['schema'] = isset( $defaultSchemas[$dbType] ) ? $defaultSchemas[$dbType] : null;
}
}
}
- /**
- * Return a path to the DBMS-specific SQL file if it exists,
- * otherwise default SQL file
- *
- * @param string $filename
- * @return string
- */
- private function getSqlFilePath( $filename ) {
- global $IP;
- $dbmsSpecificFilePath = "$IP/maintenance/" . $this->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
- *
- * @return string
- */
- public function getSchemaPath() {
- return $this->getSqlFilePath( 'tables.sql' );
- }
-
- /**
- * Return a path to the DBMS-specific update key file,
- * otherwise default to update-keys.sql
- *
- * @return string
- */
- public function getUpdateKeysPath() {
- return $this->getSqlFilePath( 'update-keys.sql' );
- }
-
/**
* Get information about an index into an object
* @param string $table Table name
return $error;
}
- /**
- * Get the full path of a patch file. Originally based on archive()
- * from updaters.inc. Keep in mind this always returns a patch, as
- * it fails back to MySQL if no DB-specific patch can be found
- *
- * @param string $patch The name of the patch, like patch-something.sql
- * @return string Full path to patch file
- */
- public function patchPath( $patch ) {
- global $IP;
-
- $dbType = $this->getType();
- if ( file_exists( "$IP/maintenance/$dbType/archives/$patch" ) ) {
- return "$IP/maintenance/$dbType/archives/$patch";
- } else {
- return "$IP/maintenance/archives/$patch";
- }
- }
-
public function setSchemaVars( $vars ) {
$this->mSchemaVars = $vars;
}