Move createTables() up a level, this code was practically identical
This commit is contained in:
parent
21216bd52d
commit
ed7ff76d50
6 changed files with 34 additions and 56 deletions
|
|
@ -276,6 +276,18 @@ abstract class DatabaseBase implements DatabaseType {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a path to the DBMS-specific schema, otherwise default to tables.sql
|
||||
*/
|
||||
public function getSchema() {
|
||||
global $IP;
|
||||
if ( file_exists( "$IP/maintenance/" . $this->getType() . "/tables.sql" ) ) {
|
||||
return "$IP/maintenance/" . $this->getType() . "/tables.sql";
|
||||
} else {
|
||||
return "$IP/maintenance/tables.sql";
|
||||
}
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Other functions
|
||||
#------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -116,7 +116,25 @@ abstract class DatabaseInstaller {
|
|||
*
|
||||
* @return Status
|
||||
*/
|
||||
public abstract function createTables();
|
||||
public function createTables() {
|
||||
$status = $this->getConnection();
|
||||
if ( !$status->isOK() ) {
|
||||
return $status;
|
||||
}
|
||||
$this->db->selectDB( $this->getVar( 'wgDBname' ) );
|
||||
|
||||
if( $this->db->tableExists( 'user' ) ) {
|
||||
$status->warning( 'config-install-tables-exist' );
|
||||
return $status;
|
||||
}
|
||||
|
||||
$error = $this->db->sourceFile( $this->db->getSchema() );
|
||||
if( $error !== true ) {
|
||||
$this->db->reportQueryError( $error, 0, $sql, __METHOD__ );
|
||||
$status->fatal( 'config-install-tables-failed', $error );
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DBMS-specific options for LocalSettings.php generation.
|
||||
|
|
|
|||
|
|
@ -466,26 +466,6 @@ class MysqlInstaller extends DatabaseInstaller {
|
|||
return $status;
|
||||
}
|
||||
|
||||
public function createTables() {
|
||||
global $IP;
|
||||
$status = $this->getConnection();
|
||||
if ( !$status->isOK() ) {
|
||||
return $status;
|
||||
}
|
||||
$this->db->selectDB( $this->getVar( 'wgDBname' ) );
|
||||
|
||||
if( $this->db->tableExists( 'user' ) ) {
|
||||
$status->warning( 'config-install-tables-exist' );
|
||||
return $status;
|
||||
}
|
||||
|
||||
$error = $this->db->sourceFile( "$IP/maintenance/tables.sql" );
|
||||
if( $error !== true ) {
|
||||
$status->fatal( 'config-install-tables-failed', $error );
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
public function getTableOptions() {
|
||||
return array( 'engine' => $this->getVar( '_MysqlEngine' ),
|
||||
'default charset' => $this->getVar( '_MysqlCharset' ) );
|
||||
|
|
|
|||
|
|
@ -96,10 +96,6 @@ class OracleInstaller extends DatabaseInstaller {
|
|||
// TODO
|
||||
}
|
||||
|
||||
public function createTables() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
public function getLocalSettings() {
|
||||
$prefix = $this->getVar( 'wgDBprefix' );
|
||||
return
|
||||
|
|
|
|||
|
|
@ -115,22 +115,6 @@ class PostgresInstaller extends DatabaseInstaller {
|
|||
function setupDatabase() {
|
||||
}
|
||||
|
||||
function createTables() {
|
||||
$status = $this->getConnection();
|
||||
if ( !$status->isOK() ) {
|
||||
return $status;
|
||||
}
|
||||
$this->db->selectDB( $this->getVar( 'wgDBname' ) );
|
||||
|
||||
global $IP;
|
||||
$err = $this->db->sourceFile( "$IP/maintenance/postgres/tables.sql" );
|
||||
if ( $err !== true ) {
|
||||
//@todo or...?
|
||||
$this->db->reportQueryError( $err, 0, $sql, __FUNCTION__ );
|
||||
}
|
||||
return Status::newGood();
|
||||
}
|
||||
|
||||
function getLocalSettings() {
|
||||
$port = $this->getVar( 'wgDBport' );
|
||||
$schema = $this->getVar( 'wgDBmwschema' );
|
||||
|
|
|
|||
|
|
@ -151,25 +151,13 @@ class SqliteInstaller extends DatabaseInstaller {
|
|||
}
|
||||
|
||||
public function createTables() {
|
||||
global $IP;
|
||||
$status = $this->getConnection();
|
||||
if ( !$status->isOK() ) {
|
||||
return $status;
|
||||
}
|
||||
// Process common MySQL/SQLite table definitions
|
||||
$err = $this->db->sourceFile( "$IP/maintenance/tables.sql" );
|
||||
if ( $err !== true ) {
|
||||
//@todo or...?
|
||||
$this->db->reportQueryError( $err, 0, $sql, __FUNCTION__ );
|
||||
}
|
||||
return $this->setupSearchIndex();
|
||||
$status = parent::createTables();
|
||||
return $this->setupSearchIndex( $status );;
|
||||
}
|
||||
|
||||
public function setupSearchIndex() {
|
||||
public function setupSearchIndex( &$status ) {
|
||||
global $IP;
|
||||
|
||||
$status = Status::newGood();
|
||||
|
||||
$module = $this->db->getFulltextSearchModule();
|
||||
$fts3tTable = $this->db->checkForEnabledSearch();
|
||||
if ( $fts3tTable && !$module ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue