From 81740c599d2186c23bd6f7d475da0728a5995a70 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Sat, 19 Jul 2014 11:51:26 -0300 Subject: [PATCH] Allow WantedQueryPage subclasses to override the existence check Some pages are still "wanted" even if the page exists. For example, consider a page in the file namespace that exists but doesn't have a corresponding file, in the context of special:wantedfiles. Change-Id: Ie40f2baea22b3564e7f06c4fa21bc1efdc0e4d54 --- includes/specialpage/WantedQueryPage.php | 29 +++++++++++++++++------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/includes/specialpage/WantedQueryPage.php b/includes/specialpage/WantedQueryPage.php index 678c803d19..be2f1e8d6e 100644 --- a/includes/specialpage/WantedQueryPage.php +++ b/includes/specialpage/WantedQueryPage.php @@ -78,15 +78,9 @@ abstract class WantedQueryPage extends QueryPage { $title = Title::makeTitleSafe( $result->namespace, $result->title ); if ( $title instanceof Title ) { if ( $this->isCached() || $this->forceExistenceCheck() ) { - $pageLink = $title->isKnown() + $pageLink = $this->existenceCheck( $title ) ? '' . Linker::link( $title ) . '' - : Linker::link( - $title, - null, - array(), - array(), - array( 'broken' ) - ); + : Linker::link( $title ); } else { $pageLink = Linker::link( $title, @@ -102,6 +96,25 @@ abstract class WantedQueryPage extends QueryPage { } } + /** + * Does the Title currently exists + * + * This method allows a subclass to override this check + * (For example, wantedfiles, would want to check if the file exists + * not just that a page in the file namespace exists). + * + * This will only control if the link is crossed out. Whether or not the link + * is blue vs red is controlled by if the title exists. + * + * @note This will only be run if the page is cached (ie $wgMiserMode = true) + * unless forceExistenceCheck() is true. + * @since 1.24 + * @return boolean + */ + protected function existenceCheck( Title $title ) { + return $title->isKnown(); + } + /** * Make a "what links here" link for a given title * -- 2.20.1