r46196 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46195‎ | r46196 | r46197 >
Date:12:43, 25 January 2009
Author:simetrical
Status:reverted (Comments)
Tags:
Comment:
__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).
Modified paths:
  • /trunk/phase3/CREDITS (modified) (history)
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/MagicWord.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUnusedcategories.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/CREDITS
@@ -56,6 +56,7 @@
5757
5858 == Patch Contributors ==
5959 * Agbad
 60+* Ahmad Sherif
6061 * Brad Jorsch
6162 * Brent G
6263 * Daniel Arnold
Index: trunk/phase3/includes/parser/Parser.php
@@ -3439,6 +3439,9 @@
34403440 wfDebug( __METHOD__.": [[MediaWiki:hidden-category-category]] is not a valid title!\n" );
34413441 }
34423442 }
 3443+ if ( isset( $this->mDoubleUnderscores['ignoreunused'] ) && $this->mTitle->getNamespace() == NS_CATEGORY ) {
 3444+ $this->mOutput->setProperty( 'ignoreunused', 'y' );
 3445+ }
34433446 # (bug 8068) Allow control over whether robots index a page.
34443447 #
34453448 # FIXME (bug 14899): __INDEX__ always overrides __NOINDEX__ here! This
Index: trunk/phase3/includes/MagicWord.php
@@ -159,6 +159,7 @@
160160 'noeditsection',
161161 'newsectionlink',
162162 'hiddencat',
 163+ 'ignoreunused',
163164 'index',
164165 'noindex',
165166 'staticredirect',
Index: trunk/phase3/includes/specials/SpecialUnusedcategories.php
@@ -22,14 +22,16 @@
2323 function getSQL() {
2424 $NScat = NS_CATEGORY;
2525 $dbr = wfGetDB( DB_SLAVE );
26 - list( $categorylinks, $page ) = $dbr->tableNamesN( 'categorylinks', 'page' );
 26+ list( $categorylinks, $page, $page_props ) = $dbr->tableNamesN( 'categorylinks', 'page', 'page_props' );
2727 return "SELECT 'Unusedcategories' as type,
2828 {$NScat} as namespace, page_title as title, page_title as value
2929 FROM $page
3030 LEFT JOIN $categorylinks ON page_title=cl_to
 31+ LEFT JOIN $page_props ON pp_page=page_id
3132 WHERE cl_from IS NULL
3233 AND page_namespace = {$NScat}
33 - AND page_is_redirect = 0";
 34+ AND page_is_redirect = 0
 35+ AND (pp_propname IS NULL OR pp_propname != 'ignoreunused')";
3436 }
3537
3638 function formatResult( $skin, $result ) {
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -327,6 +327,7 @@
328328 'filepath' => array( 0, 'FILEPATH:' ),
329329 'tag' => array( 0, 'tag' ),
330330 'hiddencat' => array( 1, '__HIDDENCAT__' ),
 331+ 'ignoreunused' => array( 1, '__IGNOREUNUSED__' ),
331332 'pagesincategory' => array( 1, 'PAGESINCATEGORY', 'PAGESINCAT' ),
332333 'pagesize' => array( 1, 'PAGESIZE' ),
333334 'index' => array( 1, '__INDEX__' ),
Index: trunk/phase3/RELEASE-NOTES
@@ -60,6 +60,8 @@
6161 link instead of Go button & Search button
6262 * (bug 2314) Add links to user custom CSS and JS to Special:Preferences
6363 * More helpful error message on raw page access if PHP_SELF isn't set
 64+* (bug 17145) Specific categories can be excluded from Special:UnusedCategories
 65+ with __IGNOREUNUSED__
6466
6567 === Bug fixes in 1.15 ===
6668 * (bug 16968) Special:Upload no longer throws useless warnings.

Follow-up revisions

RevisionCommit summaryAuthorDate
r46395Roll back r46196, 46202 for now "__IGNOREUNUSED__ excludes cats from UnusedCa...brion22:54, 27 January 2009

Comments

#Comment by P.Copp (talk | contribs)   14:16, 25 January 2009
+				LEFT JOIN $page_props ON pp_page=page_id
...
+				AND (pp_propname IS NULL OR pp_propname != 'ignoreunused')";

This left join will return multiple results for one category, if someday there will be more properties. Moreover, if using __HIDDENCAT__ and __IGNOREUNUSED__ on the same category, will list the cat on Special:UnusedCategories anyhow. AFAICT the SQL has to look somehow like that:

+				LEFT JOIN $page_props ON (pp_page=page_id AND pp_propname = 'ignoreunused')
...
+				AND pp_propname IS NULL;
#Comment by Simetrical (talk | contribs)   15:24, 25 January 2009

Oops! Of course you're right. Fixed in r46202.

#Comment by Brion VIBBER (talk | contribs)   23:57, 26 January 2009

I find the name pretty confusing; it's completely unobvious what __IGNOREUNUSED__ means.

#Comment by Simetrical (talk | contribs)   02:26, 27 January 2009

I couldn't think of any better one . . . previously it was __USED__ (which is misleading), then __NOUNUSED__ (which is completely confusing). It's impossible to figure out what __IGNOREUNUSED__ means without looking it up, but at least it's not actively misleading. Something like __USEDCATEGORY__ might give a better hint to what it does, if the reader has heard of Special:UnusedCategories, although it's also sort of misleading.

It's hard to explain such a narrow purpose in two words or so. Maybe __USEDCATEGORY__ is a better choice, though?

#Comment by Brion VIBBER (talk | contribs)   22:55, 27 January 2009

Reverted for now in r46395 pending working out a final name.

Status & tagging log