Bug 28478: database error in DatabaseSqlite::getFulltextSearchModule().
authorMax Semenik <maxsem@users.mediawiki.org>
Mon, 11 Apr 2011 17:16:41 +0000 (17:16 +0000)
committerMax Semenik <maxsem@users.mediawiki.org>
Mon, 11 Apr 2011 17:16:41 +0000 (17:16 +0000)
It was caused by a weird bug in SQLite: virtual table using a non-existent module still gets created somehow, and it is completely undeletable.

includes/db/DatabaseSqlite.php
includes/installer/Installer.php
includes/installer/SqliteInstaller.php
includes/installer/SqliteUpdater.php
maintenance/rebuildtextindex.php

index 1ad8f6e..e7bc31e 100644 (file)
@@ -130,19 +130,20 @@ class DatabaseSqlite extends DatabaseBase {
         * Returns version of currently supported SQLite fulltext search module or false if none present.
         * @return String
         */
-       function getFulltextSearchModule() {
+       static function getFulltextSearchModule() {
                static $cachedResult = null;
                if ( $cachedResult !== null ) {
                        return $cachedResult;
                }
                $cachedResult = false;
                $table = 'dummy_search_test';
-               $this->query( "DROP TABLE IF EXISTS $table", __METHOD__ );
+               
+               $db = new DatabaseSqliteStandalone( ':memory:' );
 
-               if ( $this->query( "CREATE VIRTUAL TABLE $table USING FTS3(dummy_field)", __METHOD__, true ) ) {
-                       $this->query( "DROP TABLE IF EXISTS $table", __METHOD__ );
+               if ( $db->query( "CREATE VIRTUAL TABLE $table USING FTS3(dummy_field)", __METHOD__, true ) ) {
                        $cachedResult = 'FTS3';
                }
+               $db->close();
                return $cachedResult;
        }
 
@@ -460,7 +461,7 @@ class DatabaseSqlite extends DatabaseBase {
         * @return string User-friendly database information
         */
        public function getServerInfo() {
-               return wfMsg( $this->getFulltextSearchModule() ? 'sqlite-has-fts' : 'sqlite-no-fts', $this->getServerVersion() );
+               return wfMsg( self::getFulltextSearchModule() ? 'sqlite-has-fts' : 'sqlite-no-fts', $this->getServerVersion() );
        }
 
        /**
index 87036c5..7b3f4f8 100644 (file)
@@ -625,8 +625,7 @@ abstract class Installer {
                // Check for FTS3 full-text search module
                $sqlite = $this->getDBInstaller( 'sqlite' );
                if ( $sqlite->isCompiled() ) {
-                       $db = new DatabaseSqliteStandalone( ':memory:' );
-                       if( $db->getFulltextSearchModule() != 'FTS3' ) {
+                       if( DatabaseSqlite::getFulltextSearchModule() != 'FTS3' ) {
                                $this->showMessage( 'config-no-fts3' );
                        }
                }
index 6b57d18..2edb3d9 100644 (file)
@@ -170,7 +170,7 @@ class SqliteInstaller extends DatabaseInstaller {
        public function setupSearchIndex( &$status ) {
                global $IP;
 
-               $module = $this->db->getFulltextSearchModule();
+               $module = DatabaseSqlite::getFulltextSearchModule();
                $fts3tTable = $this->db->checkForEnabledSearch();
                if ( $fts3tTable &&  !$module ) {
                        $status->warning( 'config-sqlite-fts3-downgrade' );
index 5cbe67a..d1a6c20 100644 (file)
@@ -67,7 +67,7 @@ class SqliteUpdater extends DatabaseUpdater {
        }
 
        protected function sqliteSetupSearchindex() {
-               $module = $this->db->getFulltextSearchModule();
+               $module = DatabaseSqlite::getFulltextSearchModule();
                $fts3tTable = $this->updateRowExists( 'fts3' );
                if ( $fts3tTable &&  !$module ) {
                        $this->output( '...PHP is missing FTS3 support, downgrading tables...' );
index deabff7..b0934eb 100644 (file)
@@ -50,11 +50,11 @@ class RebuildTextIndex extends Maintenance {
 
                $this->db = wfGetDB( DB_MASTER );
                if ( $this->db->getType() == 'sqlite' ) {
-                       if ( !$this->db->getFulltextSearchModule() ) {
-                               $this->error( "Your version of SQLite module for PHP doesn't support full-text search (FTS3).\n" );
+                       if ( !DatabaseSqlite::getFulltextSearchModule() ) {
+                               $this->error( "Your version of SQLite module for PHP doesn't support full-text search (FTS3).\n", true );
                        }
                        if ( !$this->db->checkForEnabledSearch() ) {
-                               $this->error( "Your database schema is not configured for full-text search support. Run update.php.\n" );
+                               $this->error( "Your database schema is not configured for full-text search support. Run update.php.\n", true );
                        }
                }