Workaround null Title error in parser during main page creation. Used $wgTitle. I...
[lhc/web/wiklou.git] / includes / installer / SqliteInstaller.php
index f977699..32d22e6 100644 (file)
@@ -1,7 +1,19 @@
 <?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 {
-       
+
        protected $globalNames = array(
                'wgDBname',
                'wgSQLiteDataDir',
@@ -29,14 +41,11 @@ class SqliteInstaller extends DatabaseInstaller {
        }
 
        public 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' );
+               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' ) );
        }
 
        public function submitConnectForm() {
-               global $wgSQLiteDataDir;
                $this->setVarsFromRequest( array( 'wgSQLiteDataDir', 'wgDBname' ) );
 
                $dir = realpath( $this->getVar( 'wgSQLiteDataDir' ) );
@@ -84,17 +93,21 @@ class SqliteInstaller extends DatabaseInstaller {
                global $wgSQLiteDataDir;
 
                $status = Status::newGood();
-               $dir = $this->getVar( 'wgSQLiteDataDir' );
-               $dbName = $this->getVar( 'wgDBname' );
-
-               try {
-                       # FIXME: need more sensible constructor parameters, e.g. single associative array
-                       # Setting globals kind of sucks
-                       $wgSQLiteDataDir = $dir;
-                       $this->db = new DatabaseSqlite( false, false, false, $dbName );
+               if( is_null( $this->db ) ) {
+                       $dir = $this->getVar( 'wgSQLiteDataDir' );
+                       $dbName = $this->getVar( 'wgDBname' );
+
+                       try {
+                               # FIXME: need more sensible constructor parameters, e.g. single associative array
+                               # Setting globals kind of sucks
+                               $wgSQLiteDataDir = $dir;
+                               $this->db = new DatabaseSqlite( false, false, false, $dbName );
+                               $status->value = $this->db;
+                       } catch ( DBConnectionError $e ) {
+                               $status->fatal( 'config-sqlite-connection-error', $e->getMessage() );
+                       }
+               } else {
                        $status->value = $this->db;
-               } catch ( DBConnectionError $e ) {
-                       $status->fatal( 'config-sqlite-connection-error', $e->getMessage() );
                }
                return $status;
        }
@@ -111,14 +124,6 @@ class SqliteInstaller extends DatabaseInstaller {
                return parent::needsUpgrade();
        }
 
-       public function getSettingsForm() {
-               return false;
-       }
-
-       public function submitSettingsForm() {
-               return Status::newGood();
-       }
-
        public function setupDatabase() {
                $dir = $this->getVar( 'wgSQLiteDataDir' );
 
@@ -148,59 +153,28 @@ 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 ) {
                        $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;
        }
 
-       public 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;
-       }
-
-       public static function outputHandler( $string ) {
-               return htmlspecialchars( $string );
-       }
-
        public function getLocalSettings() {
                $dir = LocalSettingsGenerator::escapePhpString( $this->getVar( 'wgSQLiteDataDir' ) );
                return
 "# SQLite-specific settings
 \$wgSQLiteDataDir    = \"{$dir}\";";
        }
-       
-}
\ No newline at end of file
+}