<?php
+/**
+ * Sqlite-specific installer.
+ *
+ * @file
+ * @ingroup Deployment
+ */
+
+/**
+ * Class for setting up the MediaWiki database using SQLLite.
+ *
+ * @ingroup Deployment
+ * @since 1.17
+ */
+class SqliteInstaller extends DatabaseInstaller {
-class SqliteInstaller extends InstallerDBType {
protected $globalNames = array(
'wgDBname',
'wgSQLiteDataDir',
);
- function getName() {
+ public function getName() {
return 'sqlite';
}
- static function isCompiled() {
+ public function isCompiled() {
return self::checkExtension( 'pdo_sqlite' );
}
- function getGlobalDefaults() {
+ public function getGlobalDefaults() {
if ( isset( $_SERVER['DOCUMENT_ROOT'] ) ) {
$path = str_replace(
array( '/', '\\' ),
}
}
- function getConnectForm() {
- return $this->getTextBox( 'wgSQLiteDataDir', 'config-sqlite-dir' ) .
- $this->parent->getHelpBox( 'config-sqlite-dir-help' ) .
- $this->getTextBox( 'wgDBname', 'config-db-name' ) .
- $this->parent->getHelpBox( 'config-sqlite-name-help' );
+ public function getConnectForm() {
+ return $this->getTextBox( 'wgSQLiteDataDir', 'config-sqlite-dir', array(), $this->parent->getHelpBox( 'config-sqlite-dir-help' ) ) .
+ $this->getTextBox( 'wgDBname', 'config-db-name', array(), $this->parent->getHelpBox( 'config-sqlite-name-help' ) );
}
- function submitConnectForm() {
- global $wgSQLiteDataDir;
+ public function submitConnectForm() {
$this->setVarsFromRequest( array( 'wgSQLiteDataDir', 'wgDBname' ) );
$dir = realpath( $this->getVar( 'wgSQLiteDataDir' ) );
return Status::newGood();
}
- function getConnection() {
+ public function getConnection() {
global $wgSQLiteDataDir;
$status = Status::newGood();
return $status;
}
- function needsUpgrade() {
+ public function needsUpgrade() {
$dir = $this->getVar( 'wgSQLiteDataDir' );
$dbName = $this->getVar( 'wgDBname' );
// Don't create the data file yet
return parent::needsUpgrade();
}
- function getSettingsForm() {
- return false;
- }
-
- function submitSettingsForm() {
- return Status::newGood();
- }
-
- function setupDatabase() {
+ public function setupDatabase() {
$dir = $this->getVar( 'wgSQLiteDataDir' );
# Sanity check. We checked this before but maybe someone deleted the
return $this->getConnection();
}
- 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();
+ public function createTables() {
+ $status = parent::createTables();
+ return $this->setupSearchIndex( $status );
}
- function setupSearchIndex() {
+ public function setupSearchIndex( &$status ) {
global $IP;
- $status = Status::newGood();
-
$module = $this->db->getFulltextSearchModule();
$fts3tTable = $this->db->checkForEnabledSearch();
if ( $fts3tTable && !$module ) {
$status->warning( 'config-sqlite-fts3-downgrade' );
$this->db->sourceFile( "$IP/maintenance/sqlite/archives/searchindex-no-fts.sql" );
} elseif ( !$fts3tTable && $module == 'FTS3' ) {
- $status->warning( 'config-sqlite-fts3-add' );
$this->db->sourceFile( "$IP/maintenance/sqlite/archives/searchindex-fts3.sql" );
- } else {
- $status->warning( 'config-sqlite-fts3-ok' );
}
-
return $status;
}
- function doUpgrade() {
- global $wgDatabase;
- LBFactory::enableBackend();
- $wgDatabase = wfGetDB( DB_MASTER );
- ob_start( array( 'SqliteInstaller', 'outputHandler' ) );
- do_all_updates( false, true );
- ob_end_flush();
- return true;
- }
-
- static function outputHandler( $string ) {
- return htmlspecialchars( $string );
- }
-
- function getLocalSettings() {
+ public function getLocalSettings() {
$dir = LocalSettingsGenerator::escapePhpString( $this->getVar( 'wgSQLiteDataDir' ) );
return
"# SQLite-specific settings