From 8ac72aa101a97a59d0dc1bdf197f6e3f0b0b002e Mon Sep 17 00:00:00 2001 From: Ilmari Karonen Date: Sat, 4 Dec 2010 16:10:51 +0000 Subject: [PATCH] Partial workaround for bug 6220: at least make files on shared repositories show up as (struck-out) bluelinks instead of redlinks on Special:WantedFiles. Also change the query slightly to join on the image table instead of page, since that would seem to make more sense. --- RELEASE-NOTES | 2 ++ includes/QueryPage.php | 15 +++++++++++++-- includes/specials/SpecialWantedfiles.php | 16 +++++++++++++--- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 3f0b5529c1..643bcd5caf 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -447,6 +447,8 @@ LocalSettings.php. The specific bugs are listed below in the general notes. * (bug 26160) Upload description set by extensions are not propagated * (bug 9675) generateSitemap.php now takes an --urlpath parameter to allow absolute URLs in the sitemap index (as required e.g. by Google) +* Partial workaround for bug 6220: at least make files on shared repositories + show up as (struck-out) bluelinks instead of redlinks on Special:WantedFiles === API changes in 1.17 === * (bug 22738) Allow filtering by action type on query=logevent. diff --git a/includes/QueryPage.php b/includes/QueryPage.php index a30157487c..d9fb3bb278 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -580,6 +580,17 @@ abstract class WantedQueryPage extends QueryPage { $db->dataSeek( $res, 0 ); } + /** + * Should formatResult() always check page existence, even if + * the results are fresh? This is a (hopefully temporary) + * kluge for Special:WantedFiles, which may contain false + * positives for files that exist e.g. in a shared repo (bug + * 6220). + */ + function forceExistenceCheck() { + return false; + } + /** * Format an individual result * @@ -590,8 +601,8 @@ abstract class WantedQueryPage extends QueryPage { public function formatResult( $skin, $result ) { $title = Title::makeTitleSafe( $result->namespace, $result->title ); if( $title instanceof Title ) { - if( $this->isCached() ) { - $pageLink = $title->exists() + if( $this->isCached() || $this->forceExistenceCheck() ) { + $pageLink = $title->isKnown() ? '' . $skin->link( $title ) . '' : $skin->link( $title, diff --git a/includes/specials/SpecialWantedfiles.php b/includes/specials/SpecialWantedfiles.php index 28e82a8f85..d6c1157b00 100644 --- a/includes/specials/SpecialWantedfiles.php +++ b/includes/specials/SpecialWantedfiles.php @@ -35,9 +35,19 @@ class WantedFilesPage extends WantedQueryPage { return 'Wantedfiles'; } + /** + * KLUGE: The results may contain false positives for files + * that exist e.g. in a shared repo. Setting this at least + * keeps them from showing up as redlinks in the output, even + * if it doesn't fix the real problem (bug 6220). + */ + function forceExistenceCheck() { + return true; + } + function getSQL() { $dbr = wfGetDB( DB_SLAVE ); - list( $imagelinks, $page ) = $dbr->tableNamesN( 'imagelinks', 'page' ); + list( $imagelinks, $image ) = $dbr->tableNamesN( 'imagelinks', 'image' ); $name = $dbr->addQuotes( $this->getName() ); return " @@ -47,8 +57,8 @@ class WantedFilesPage extends WantedQueryPage { il_to as title, COUNT(*) as value FROM $imagelinks - LEFT JOIN $page ON il_to = page_title AND page_namespace = ". NS_FILE ." - WHERE page_title IS NULL + LEFT JOIN $image ON il_to = img_name + WHERE img_name IS NULL GROUP BY il_to "; } -- 2.20.1