Index: branches/sqlite/includes/search/SearchSqlite.php |
— | — | @@ -28,6 +28,9 @@ |
29 | 29 | class SearchSqlite extends SearchEngine { |
30 | 30 | var $strictMatching = true; |
31 | 31 | |
| 32 | + // Cached because SearchUpdate keeps recreating our class |
| 33 | + private static $fulltextSupported = NULL; |
| 34 | + |
32 | 35 | /** |
33 | 36 | * Creates an instance of this class |
34 | 37 | * @param $db DatabaseSqlite: database object |
— | — | @@ -36,6 +39,19 @@ |
37 | 40 | $this->db = $db; |
38 | 41 | } |
39 | 42 | |
| 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 | + |
40 | 56 | /** |
41 | 57 | * Parse the user's query and transform it into an SQL fragment which will |
42 | 58 | * become part of a WHERE clause |
— | — | @@ -165,7 +181,11 @@ |
166 | 182 | |
167 | 183 | protected function searchInternal( $term, $fulltext ) { |
168 | 184 | global $wgSearchMySQLTotalHits; |
169 | | - |
| 185 | + |
| 186 | + if ( !$this->fulltextSearchSupported() ) { |
| 187 | + return null; |
| 188 | + } |
| 189 | + |
170 | 190 | $filteredTerm = $this->filter( $term ); |
171 | 191 | $resultSet = $this->db->query( $this->getQuery( $filteredTerm, $fulltext ) ); |
172 | 192 | |
— | — | @@ -288,6 +308,9 @@ |
289 | 309 | * @param $text String |
290 | 310 | */ |
291 | 311 | function update( $id, $title, $text ) { |
| 312 | + if ( !$this->fulltextSearchSupported() ) { |
| 313 | + return; |
| 314 | + } |
292 | 315 | // @todo: find a method to do it in a single request, |
293 | 316 | // couldn't do it so far due to typelessness of FTS3 tables. |
294 | 317 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -310,6 +333,9 @@ |
311 | 334 | * @param $title String |
312 | 335 | */ |
313 | 336 | function updateTitle( $id, $title ) { |
| 337 | + if ( !$this->fulltextSearchSupported() ) { |
| 338 | + return; |
| 339 | + } |
314 | 340 | $dbw = wfGetDB( DB_MASTER ); |
315 | 341 | |
316 | 342 | $dbw->update( 'searchindex', |