* (bug 12846) IE rtl.css issue in RTL wikis special:Preferences when selecting an
LTR user language
* (bug 13005) DISPLAYTITLE does not work on preview
+* (bug 13004) Fix error on Postgres searches that return too many results.
== Parser changes in 1.12 ==
}
+/**
+ * @addtogroup Search
+ */
+class SearchResultTooMany {
+ ## Some search engines may bail out if too many matches are found
+}
+
+
/**
* @addtogroup Search
*/
class SearchResult {
+
function SearchResult( $row ) {
$this->mTitle = Title::makeTitle( $row->page_namespace, $row->page_title );
}
* @access public
*/
function searchTitle( $term ) {
- $resultSet = $this->db->resultObject( $this->db->query( $this->searchQuery( $term , 'titlevector', 'page_title' )));
+ $q = $this->searchQuery( $term , 'titlevector', 'page_title' );
+ $olderror = error_reporting(E_ERROR);
+ $resultSet = $this->db->resultObject( $this->db->query( $q, 'SearchPostgres', true ) );
+ error_reporting($olderror);
+ if (!$resultSet) {
+ // Needed for "Query requires full scan, GIN doesn't support it"
+ return new SearchResultTooMany();
+ }
return new PostgresSearchResultSet( $resultSet, $this->searchTerms );
}
function searchText( $term ) {
- $resultSet = $this->db->resultObject( $this->db->query( $this->searchQuery( $term, 'textvector', 'old_text' )));
+ $q = $this->searchQuery( $term, 'textvector', 'old_text' );
+ $olderror = error_reporting(E_ERROR);
+ $resultSet = $this->db->resultObject( $this->db->query( $q, 'SearchPostgres', true ) );
+ error_reporting($olderror);
+ if (!$resultSet) {
+ return new SearchResultTooMany();
+ }
return new PostgresSearchResultSet( $resultSet, $this->searchTerms );
}
$search->setNamespaces( $this->namespaces );
$search->showRedirects = $this->searchRedirects;
$titleMatches = $search->searchTitle( $term );
+
+ // Sometimes the search engine knows there are too many hits
+ if ($titleMatches instanceof SearchResultTooMany) {
+ $wgOut->addWikiText( '==' . wfMsg( 'toomanymatches' ) . "==\n" );
+ $wgOut->addHTML( $this->powerSearchBox( $term ) );
+ $wgOut->addHTML( $this->powerSearchFocus() );
+ wfProfileOut( $fname );
+ return;
+ }
$textMatches = $search->searchText( $term );
$num = ( $titleMatches ? $titleMatches->numRows() : 0 )
'searchsubtitleinvalid' => "You searched for '''$1'''",
'noexactmatch' => "'''There is no page titled \"\$1\".''' You can [[:\$1|create this page]].",
'noexactmatch-nocreate' => "'''There is no page titled \"\$1\".'''",
+'toomanymatches' => 'Too many matches were returned, please try a different query',
'titlematches' => 'Page title matches',
'notitlematches' => 'No page title matches',
'textmatches' => 'Page text matches',