r58293 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58292‎ | r58293 | r58294 >
Date:22:26, 28 October 2009
Author:maxsem
Status:deferred
Tags:
Comment:
Don't fail with SQL exception if FTS is not supported
Modified paths:
  • /branches/sqlite/includes/search/SearchSqlite.php (modified) (history)

Diff [purge]

Index: branches/sqlite/includes/search/SearchSqlite.php
@@ -28,6 +28,9 @@
2929 class SearchSqlite extends SearchEngine {
3030 var $strictMatching = true;
3131
 32+ // Cached because SearchUpdate keeps recreating our class
 33+ private static $fulltextSupported = NULL;
 34+
3235 /**
3336 * Creates an instance of this class
3437 * @param $db DatabaseSqlite: database object
@@ -36,6 +39,19 @@
3740 $this->db = $db;
3841 }
3942
 43+ /**
 44+ * Whether fulltext search is supported by current schema
 45+ * @return Boolean
 46+ */
 47+ function fulltextSearchSupported() {
 48+ if ( self::$fulltextSupported === NULL ) {
 49+ $res = $this->db->selectField( 'updatelog', 'ul_key', array( 'ul_key' => 'fts3' ), __METHOD__ );
 50+ self::$fulltextSupported = $res && $this->db->numRows( $res ) > 0;
 51+ }
 52+ wfDebug( "*************************************************************" . self::$fulltextSupported . "****************\n" );
 53+ return self::$fulltextSupported;
 54+ }
 55+
4056 /**
4157 * Parse the user's query and transform it into an SQL fragment which will
4258 * become part of a WHERE clause
@@ -165,7 +181,11 @@
166182
167183 protected function searchInternal( $term, $fulltext ) {
168184 global $wgSearchMySQLTotalHits;
169 -
 185+
 186+ if ( !$this->fulltextSearchSupported() ) {
 187+ return null;
 188+ }
 189+
170190 $filteredTerm = $this->filter( $term );
171191 $resultSet = $this->db->query( $this->getQuery( $filteredTerm, $fulltext ) );
172192
@@ -288,6 +308,9 @@
289309 * @param $text String
290310 */
291311 function update( $id, $title, $text ) {
 312+ if ( !$this->fulltextSearchSupported() ) {
 313+ return;
 314+ }
292315 // @todo: find a method to do it in a single request,
293316 // couldn't do it so far due to typelessness of FTS3 tables.
294317 $dbw = wfGetDB( DB_MASTER );
@@ -310,6 +333,9 @@
311334 * @param $title String
312335 */
313336 function updateTitle( $id, $title ) {
 337+ if ( !$this->fulltextSearchSupported() ) {
 338+ return;
 339+ }
314340 $dbw = wfGetDB( DB_MASTER );
315341
316342 $dbw->update( 'searchindex',

Status & tagging log