From 4ac9fa081a7c045f6a9f1cfc529d82423f485b2e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Dec 2013 09:55:49 +0100 Subject: Update to MediaWiki 1.22.0 --- includes/search/SearchSqlite.php | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'includes/search/SearchSqlite.php') diff --git a/includes/search/SearchSqlite.php b/includes/search/SearchSqlite.php index f3f4788c..554181f6 100644 --- a/includes/search/SearchSqlite.php +++ b/includes/search/SearchSqlite.php @@ -61,12 +61,12 @@ class SearchSqlite extends SearchEngine { $this->searchTerms = array(); $m = array(); - if( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', + if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', $filteredText, $m, PREG_SET_ORDER ) ) { - foreach( $m as $bits ) { + foreach ( $m as $bits ) { @list( /* all */, $modifier, $term, $nonQuoted, $wildcard ) = $bits; - if( $nonQuoted != '' ) { + if ( $nonQuoted != '' ) { $term = $nonQuoted; $quote = ''; } else { @@ -74,14 +74,14 @@ class SearchSqlite extends SearchEngine { $quote = '"'; } - if( $searchon !== '' ) { + if ( $searchon !== '' ) { $searchon .= ' '; } // Some languages such as Serbian store the input form in the search index, // so we may need to search for matches in multiple writing system variants. $convertedVariants = $wgContLang->autoConvertToAllVariants( $term ); - if( is_array( $convertedVariants ) ) { + if ( is_array( $convertedVariants ) ) { $variants = array_unique( array_values( $convertedVariants ) ); } else { $variants = array( $term ); @@ -101,10 +101,11 @@ class SearchSqlite extends SearchEngine { $strippedVariants = array_unique( $strippedVariants ); $searchon .= $modifier; - if( count( $strippedVariants) > 1 ) + if ( count( $strippedVariants ) > 1 ) { $searchon .= '('; - foreach( $strippedVariants as $stripped ) { - if( $nonQuoted && strpos( $stripped, ' ' ) !== false ) { + } + foreach ( $strippedVariants as $stripped ) { + if ( $nonQuoted && strpos( $stripped, ' ' ) !== false ) { // Hack for Chinese: we need to toss in quotes for // multiple-character phrases since normalizeForSearch() // added spaces between them to make word breaks. @@ -112,8 +113,9 @@ class SearchSqlite extends SearchEngine { } $searchon .= "$quote$stripped$quote$wildcard "; } - if( count( $strippedVariants) > 1 ) + if ( count( $strippedVariants ) > 1 ) { $searchon .= ')'; + } // Match individual terms or quoted phrase in result highlighting... // Note that variants will be introduced in a later stage for highlighting! @@ -134,8 +136,8 @@ class SearchSqlite extends SearchEngine { global $wgContLang; $regex = preg_quote( $string, '/' ); - if( $wgContLang->hasWordBreaks() ) { - if( $wildcard ) { + if ( $wgContLang->hasWordBreaks() ) { + if ( $wildcard ) { // Don't cut off the final bit! $regex = "\b$regex"; } else { @@ -184,10 +186,10 @@ class SearchSqlite extends SearchEngine { $resultSet = $this->db->query( $this->getQuery( $filteredTerm, $fulltext ) ); $total = null; - if( $wgCountTotalSearchHits ) { + if ( $wgCountTotalSearchHits ) { $totalResult = $this->db->query( $this->getCountQuery( $filteredTerm, $fulltext ) ); $row = $totalResult->fetchObject(); - if( $row ) { + if ( $row ) { $total = intval( $row->c ); } $totalResult->free(); @@ -201,7 +203,7 @@ class SearchSqlite extends SearchEngine { * @return String */ function queryRedirect() { - if( $this->showRedirects ) { + if ( $this->showRedirects ) { return ''; } else { return 'AND page_is_redirect=0'; @@ -213,8 +215,9 @@ class SearchSqlite extends SearchEngine { * @return String */ function queryNamespaces() { - if( is_null( $this->namespaces ) ) + if ( is_null( $this->namespaces ) ) { return ''; # search all + } if ( !count( $this->namespaces ) ) { $namespaces = '0'; } else { @@ -295,7 +298,7 @@ class SearchSqlite extends SearchEngine { if ( !$this->fulltextSearchSupported() ) { return; } - // @todo: find a method to do it in a single request, + // @todo find a method to do it in a single request, // couldn't do it so far due to typelessness of FTS3 tables. $dbw = wfGetDB( DB_MASTER ); @@ -324,7 +327,7 @@ class SearchSqlite extends SearchEngine { $dbw->update( 'searchindex', array( 'si_title' => $title ), - array( 'rowid' => $id ), + array( 'rowid' => $id ), __METHOD__ ); } } @@ -333,7 +336,7 @@ class SearchSqlite extends SearchEngine { * @ingroup Search */ class SqliteSearchResultSet extends SqlSearchResultSet { - function __construct( $resultSet, $terms, $totalHits=null ) { + function __construct( $resultSet, $terms, $totalHits = null ) { parent::__construct( $resultSet, $terms ); $this->mTotalHits = $totalHits; } -- cgit v1.2.3-54-g00ecf