r85803 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85802‎ | r85803 | r85804 >
Date:17:16, 11 April 2011
Author:maxsem
Status:ok
Tags:
Comment:
Bug 28478: database error in DatabaseSqlite::getFulltextSearchModule().

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.
Modified paths:
  • /trunk/phase3/includes/db/DatabaseSqlite.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.php (modified) (history)
  • /trunk/phase3/includes/installer/SqliteInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/SqliteUpdater.php (modified) (history)
  • /trunk/phase3/maintenance/rebuildtextindex.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/rebuildtextindex.php
@@ -50,11 +50,11 @@
5151
5252 $this->db = wfGetDB( DB_MASTER );
5353 if ( $this->db->getType() == 'sqlite' ) {
54 - if ( !$this->db->getFulltextSearchModule() ) {
55 - $this->error( "Your version of SQLite module for PHP doesn't support full-text search (FTS3).\n" );
 54+ if ( !DatabaseSqlite::getFulltextSearchModule() ) {
 55+ $this->error( "Your version of SQLite module for PHP doesn't support full-text search (FTS3).\n", true );
5656 }
5757 if ( !$this->db->checkForEnabledSearch() ) {
58 - $this->error( "Your database schema is not configured for full-text search support. Run update.php.\n" );
 58+ $this->error( "Your database schema is not configured for full-text search support. Run update.php.\n", true );
5959 }
6060 }
6161
Index: trunk/phase3/includes/db/DatabaseSqlite.php
@@ -130,19 +130,20 @@
131131 * Returns version of currently supported SQLite fulltext search module or false if none present.
132132 * @return String
133133 */
134 - function getFulltextSearchModule() {
 134+ static function getFulltextSearchModule() {
135135 static $cachedResult = null;
136136 if ( $cachedResult !== null ) {
137137 return $cachedResult;
138138 }
139139 $cachedResult = false;
140140 $table = 'dummy_search_test';
141 - $this->query( "DROP TABLE IF EXISTS $table", __METHOD__ );
 141+
 142+ $db = new DatabaseSqliteStandalone( ':memory:' );
142143
143 - if ( $this->query( "CREATE VIRTUAL TABLE $table USING FTS3(dummy_field)", __METHOD__, true ) ) {
144 - $this->query( "DROP TABLE IF EXISTS $table", __METHOD__ );
 144+ if ( $db->query( "CREATE VIRTUAL TABLE $table USING FTS3(dummy_field)", __METHOD__, true ) ) {
145145 $cachedResult = 'FTS3';
146146 }
 147+ $db->close();
147148 return $cachedResult;
148149 }
149150
@@ -460,7 +461,7 @@
461462 * @return string User-friendly database information
462463 */
463464 public function getServerInfo() {
464 - return wfMsg( $this->getFulltextSearchModule() ? 'sqlite-has-fts' : 'sqlite-no-fts', $this->getServerVersion() );
 465+ return wfMsg( self::getFulltextSearchModule() ? 'sqlite-has-fts' : 'sqlite-no-fts', $this->getServerVersion() );
465466 }
466467
467468 /**
Index: trunk/phase3/includes/installer/Installer.php
@@ -625,8 +625,7 @@
626626 // Check for FTS3 full-text search module
627627 $sqlite = $this->getDBInstaller( 'sqlite' );
628628 if ( $sqlite->isCompiled() ) {
629 - $db = new DatabaseSqliteStandalone( ':memory:' );
630 - if( $db->getFulltextSearchModule() != 'FTS3' ) {
 629+ if( DatabaseSqlite::getFulltextSearchModule() != 'FTS3' ) {
631630 $this->showMessage( 'config-no-fts3' );
632631 }
633632 }
Index: trunk/phase3/includes/installer/SqliteInstaller.php
@@ -170,7 +170,7 @@
171171 public function setupSearchIndex( &$status ) {
172172 global $IP;
173173
174 - $module = $this->db->getFulltextSearchModule();
 174+ $module = DatabaseSqlite::getFulltextSearchModule();
175175 $fts3tTable = $this->db->checkForEnabledSearch();
176176 if ( $fts3tTable && !$module ) {
177177 $status->warning( 'config-sqlite-fts3-downgrade' );
Index: trunk/phase3/includes/installer/SqliteUpdater.php
@@ -67,7 +67,7 @@
6868 }
6969
7070 protected function sqliteSetupSearchindex() {
71 - $module = $this->db->getFulltextSearchModule();
 71+ $module = DatabaseSqlite::getFulltextSearchModule();
7272 $fts3tTable = $this->updateRowExists( 'fts3' );
7373 if ( $fts3tTable && !$module ) {
7474 $this->output( '...PHP is missing FTS3 support, downgrading tables...' );

Follow-up revisions

RevisionCommit summaryAuthorDate
r864741.17: MFT r81731, r85377, r85547, r85555, r85583, r85803, r85881, r86100, r86...catrope13:22, 20 April 2011

Status & tagging log