diff --git a/docs/hooks.txt b/docs/hooks.txt index 7844aaf48c8..3560856cce2 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1703,6 +1703,11 @@ in the $searchEngine->namespaces array. $query : Original query. &$parsed : Resultant query with the prefixes stripped. +'SearchResultInitFromTitle': Set the revision used when displaying a page in +search results. +$title : Current Title object being displayed in search results. +&$id: Revision ID (default is false, for latest) + 'SearchableNamespaces': An option to modify which namespaces are searchable. &$arr : Array of namespaces ($nsId => $name) which will be used. diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index b50559224de..2ccb6d3164d 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -756,8 +756,10 @@ class SearchResult { protected function initFromTitle( $title ) { $this->mTitle = $title; if ( !is_null( $this->mTitle ) ) { + $id = false; + wfRunHooks( 'SearchResultInitFromTitle', array( $title, &$id ) ); $this->mRevision = Revision::newFromTitle( - $this->mTitle, false, Revision::READ_NORMAL ); + $this->mTitle, $id, Revision::READ_NORMAL ); if ( $this->mTitle->getNamespace() === NS_FILE ) $this->mImage = wfFindFile( $this->mTitle ); }