Jump to content

Extension:Approved Revs/MediaWiki search patch

From mediawiki.org

If you have Approved Revs 0.6.2 or later, MediaWiki search will correctly find pages based on the text in their approved revision. However, if you're using MediaWiki 1.19 or earlier (or a pre-release version of MediaWiki 1.20), the results will not be fully displayed correctly for pages whose approved revision is not their latest. To get the results displayed correctly, you will probably need to apply a small patch onto the MediaWiki code. This patch depends on your version of MediaWiki; below are the two options.

MediaWiki 1.16 - 1.19

[edit]

In the file includes/search/SearchEngine.php, in the function initFromTitle(), change the line:

                        $this->mRevision = Revision::newFromTitle( $this->mTitle );

to:

                        $id = false;
                        wfRunHooks( 'SearchResultInitFromTitle', array( $title, &$id ) );
                        $this->mRevision = Revision::newFromTitle( $this->mTitle, $id );

MediaWiki 1.20 (pre-release versions)

[edit]

In the file includes/search/SearchEngine.php, in the function initFromTitle(), around line 760, change the lines:

                        $this->mRevision = Revision::newFromTitle(
                                $this->mTitle, false, Revision::AVOID_MASTER );

to:

                        $id = false;
                        wfRunHooks( 'SearchResultInitFromTitle', array( $title, &$id ) );
                        $this->mRevision = Revision::newFromTitle(
                                $this->mTitle, $id, Revision::AVOID_MASTER );