diff options
Diffstat (limited to 'includes/search')
-rw-r--r-- | includes/search/SearchEngine.php | 4 | ||||
-rw-r--r-- | includes/search/SearchHighlighter.php | 2 | ||||
-rw-r--r-- | includes/search/SearchMySQL.php | 6 | ||||
-rw-r--r-- | includes/search/SearchPostgres.php | 2 | ||||
-rw-r--r-- | includes/search/SearchResultSet.php | 35 | ||||
-rw-r--r-- | includes/search/SearchSqlite.php | 4 |
6 files changed, 43 insertions, 10 deletions
diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index 5770276a..e5ed23f5 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -33,7 +33,7 @@ class SearchEngine { /** @var string */ public $prefix = ''; - /** @var int[] */ + /** @var int[]|null */ public $namespaces = array( NS_MAIN ); /** @var int */ @@ -293,7 +293,7 @@ class SearchEngine { * Set which namespaces the search should include. * Give an array of namespace index numbers. * - * @param array $namespaces + * @param int[]|null $namespaces */ function setNamespaces( $namespaces ) { $this->namespaces = $namespaces; diff --git a/includes/search/SearchHighlighter.php b/includes/search/SearchHighlighter.php index 5087e8d5..7d5d38f2 100644 --- a/includes/search/SearchHighlighter.php +++ b/includes/search/SearchHighlighter.php @@ -218,7 +218,7 @@ class SearchHighlighter { } // calc by how much to extend existing snippets - $targetchars = intval( ( $contextchars * $contextlines ) / count ( $snippets ) ); + $targetchars = intval( ( $contextchars * $contextlines ) / count( $snippets ) ); } foreach ( $snippets as $index => $line ) { diff --git a/includes/search/SearchMySQL.php b/includes/search/SearchMySQL.php index 485088cb..246f1155 100644 --- a/includes/search/SearchMySQL.php +++ b/includes/search/SearchMySQL.php @@ -54,9 +54,9 @@ class SearchMySQL extends SearchDatabase { if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', $filteredText, $m, PREG_SET_ORDER ) ) { foreach ( $m as $bits ) { - wfSuppressWarnings(); + MediaWiki\suppressWarnings(); list( /* all */, $modifier, $term, $nonQuoted, $wildcard ) = $bits; - wfRestoreWarnings(); + MediaWiki\restoreWarnings(); if ( $nonQuoted != '' ) { $term = $nonQuoted; @@ -439,7 +439,7 @@ class SearchMySQL extends SearchDatabase { $sql = "SHOW GLOBAL VARIABLES LIKE 'ft\\_min\\_word\\_len'"; $dbr = wfGetDB( DB_SLAVE ); - $result = $dbr->query( $sql ); + $result = $dbr->query( $sql, __METHOD__ ); $row = $result->fetchObject(); $result->free(); diff --git a/includes/search/SearchPostgres.php b/includes/search/SearchPostgres.php index bda10b0b..71e3b635 100644 --- a/includes/search/SearchPostgres.php +++ b/includes/search/SearchPostgres.php @@ -186,7 +186,7 @@ class SearchPostgres extends SearchDatabase { function update( $pageid, $title, $text ) { ## We don't want to index older revisions $sql = "UPDATE pagecontent SET textvector = NULL WHERE textvector IS NOT NULL and old_id IN " . - "(SELECT rev_text_id FROM revision WHERE rev_page = " . intval( $pageid ) . + "(SELECT DISTINCT rev_text_id FROM revision WHERE rev_page = " . intval( $pageid ) . " ORDER BY rev_text_id DESC OFFSET 1)"; $this->db->query( $sql ); return true; diff --git a/includes/search/SearchResultSet.php b/includes/search/SearchResultSet.php index 406d322d..8d18b0e6 100644 --- a/includes/search/SearchResultSet.php +++ b/includes/search/SearchResultSet.php @@ -25,6 +25,12 @@ * @ingroup Search */ class SearchResultSet { + protected $containedSyntax = false; + + public function __construct( $containedSyntax = false ) { + $this->containedSyntax = $containedSyntax; + } + /** * Fetch an array of regular expression fragments for matching * the search terms as parsed by this engine in a text extract. @@ -55,6 +61,33 @@ class SearchResultSet { } /** + * Some search modes will run an alternative query that it thinks gives + * a better result than the provided search. Returns true if this has + * occured. + * + * @return bool + */ + function hasRewrittenQuery() { + return false; + } + + /** + * @return string|null The search the query was internally rewritten to, + * or null when the result of the original query was returned. + */ + function getQueryAfterRewrite() { + return null; + } + + /** + * @return string|null Same as self::getQueryAfterRewrite(), but in HTML + * and with changes highlighted. Null when the query was not rewritten. + */ + function getQueryAfterRewriteSnippet() { + return null; + } + + /** * Some search modes return a suggested alternate term if there are * no exact hits. Returns true if there is one on this set. * @@ -120,7 +153,7 @@ class SearchResultSet { * @return bool */ public function searchContainedSyntax() { - return false; + return $this->containedSyntax; } } diff --git a/includes/search/SearchSqlite.php b/includes/search/SearchSqlite.php index eee69307..3a5ee0ef 100644 --- a/includes/search/SearchSqlite.php +++ b/includes/search/SearchSqlite.php @@ -52,9 +52,9 @@ class SearchSqlite extends SearchDatabase { if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', $filteredText, $m, PREG_SET_ORDER ) ) { foreach ( $m as $bits ) { - wfSuppressWarnings(); + MediaWiki\suppressWarnings(); list( /* all */, $modifier, $term, $nonQuoted, $wildcard ) = $bits; - wfRestoreWarnings(); + MediaWiki\restoreWarnings(); if ( $nonQuoted != '' ) { $term = $nonQuoted; |