From 9ee6ef5cc5d3568d6cfc4e3da699f13289d5c3f0 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Sun, 25 Jan 2009 12:43:55 +0000 Subject: [PATCH] __IGNOREUNUSED__ excludes cats from UnusedCategories An extra left join and filter condition added to the query. Should cause no significant performance issues. Patch by Ahmad Sherif (bug 17145). --- CREDITS | 1 + RELEASE-NOTES | 2 ++ includes/MagicWord.php | 1 + includes/parser/Parser.php | 3 +++ includes/specials/SpecialUnusedcategories.php | 6 ++++-- languages/messages/MessagesEn.php | 1 + 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CREDITS b/CREDITS index f21448aecc..adb1d86469 100644 --- a/CREDITS +++ b/CREDITS @@ -56,6 +56,7 @@ following names for their contribution to the product. == Patch Contributors == * Agbad +* Ahmad Sherif * Brad Jorsch * Brent G * Daniel Arnold diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 6153ba1b2f..237f33ba1d 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -60,6 +60,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN link instead of Go button & Search button * (bug 2314) Add links to user custom CSS and JS to Special:Preferences * More helpful error message on raw page access if PHP_SELF isn't set +* (bug 17145) Specific categories can be excluded from Special:UnusedCategories + with __IGNOREUNUSED__ === Bug fixes in 1.15 === * (bug 16968) Special:Upload no longer throws useless warnings. diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 5b5b77f0ff..2700273c4e 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -159,6 +159,7 @@ class MagicWord { 'noeditsection', 'newsectionlink', 'hiddencat', + 'ignoreunused', 'index', 'noindex', 'staticredirect', diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index b8c1325a7e..e79f8cf4a4 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3439,6 +3439,9 @@ class Parser wfDebug( __METHOD__.": [[MediaWiki:hidden-category-category]] is not a valid title!\n" ); } } + if ( isset( $this->mDoubleUnderscores['ignoreunused'] ) && $this->mTitle->getNamespace() == NS_CATEGORY ) { + $this->mOutput->setProperty( 'ignoreunused', 'y' ); + } # (bug 8068) Allow control over whether robots index a page. # # FIXME (bug 14899): __INDEX__ always overrides __NOINDEX__ here! This diff --git a/includes/specials/SpecialUnusedcategories.php b/includes/specials/SpecialUnusedcategories.php index 406f794409..ced32d92e4 100644 --- a/includes/specials/SpecialUnusedcategories.php +++ b/includes/specials/SpecialUnusedcategories.php @@ -22,14 +22,16 @@ class UnusedCategoriesPage extends QueryPage { function getSQL() { $NScat = NS_CATEGORY; $dbr = wfGetDB( DB_SLAVE ); - list( $categorylinks, $page ) = $dbr->tableNamesN( 'categorylinks', 'page' ); + list( $categorylinks, $page, $page_props ) = $dbr->tableNamesN( 'categorylinks', 'page', 'page_props' ); return "SELECT 'Unusedcategories' as type, {$NScat} as namespace, page_title as title, page_title as value FROM $page LEFT JOIN $categorylinks ON page_title=cl_to + LEFT JOIN $page_props ON pp_page=page_id WHERE cl_from IS NULL AND page_namespace = {$NScat} - AND page_is_redirect = 0"; + AND page_is_redirect = 0 + AND (pp_propname IS NULL OR pp_propname != 'ignoreunused')"; } function formatResult( $skin, $result ) { diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index b57631a4be..4f153947c9 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -327,6 +327,7 @@ $magicWords = array( 'filepath' => array( 0, 'FILEPATH:' ), 'tag' => array( 0, 'tag' ), 'hiddencat' => array( 1, '__HIDDENCAT__' ), + 'ignoreunused' => array( 1, '__IGNOREUNUSED__' ), 'pagesincategory' => array( 1, 'PAGESINCATEGORY', 'PAGESINCAT' ), 'pagesize' => array( 1, 'PAGESIZE' ), 'index' => array( 1, '__INDEX__' ), -- 2.20.1