r47530 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47529‎ | r47530 | r47531 >
Date:06:47, 20 February 2009
Author:philip
Status:reverted (Comments)
Tags:
Comment:
Fix bug 17571, now page1 would add to both cat1 and cat2.
Modified paths:
  • /trunk/phase3/includes/LinksUpdate.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/LinksUpdate.php
@@ -427,18 +427,25 @@
428428 function getCategoryInsertions( $existing = array() ) {
429429 global $wgContLang;
430430 $diffs = array_diff_assoc( $this->mCategories, $existing );
431 - $arr = array();
432 - foreach ( $diffs as $name => $sortkey ) {
433 - $nt = Title::makeTitleSafe( NS_CATEGORY, $name );
434 - $wgContLang->findVariantLink( $name, $nt, true );
 431+ foreach ( $this->mCategories as $name => $sortkey ) {
 432+ $newname = $name;
 433+ $nt = Title::makeTitleSafe( NS_CATEGORY, $newname );
 434+ $wgContLang->findVariantLink( $newname, $nt, true );
435435 // for category redirection
436436 if ( $nt->isRedirect() ) {
437437 $at = new Article( $nt );
438438 $nt = $at->getRedirectTarget();
 439+ $newname = $nt->getText();
439440 // we only redirect a category to another category
440 - if ( $nt->getNamespace() == NS_CATEGORY )
441 - $name = $nt->getText();
 441+ if ( ! array_key_exists( $newname, $existing )
 442+ and $nt->getNamespace() == NS_CATEGORY )
 443+ $diffs[$newname] = $sortkey;
442444 }
 445+ }
 446+ $arr = array();
 447+ foreach ( $diffs as $name => $sortkey ) {
 448+ $nt = Title::makeTitleSafe( NS_CATEGORY, $name );
 449+ $wgContLang->findVariantLink( $name, $nt, true );
443450 $arr[] = array(
444451 'cl_from' => $this->mId,
445452 'cl_to' => $name,

Follow-up revisions

RevisionCommit summaryAuthorDate
r48796Revert r47530 "Fix bug 17571, now page1 would add to both cat1 and cat2."...brion08:46, 25 March 2009

Comments

#Comment by Brion VIBBER (talk | contribs)   23:35, 3 March 2009

This just strikes me as wrong, or at the least confusing. :) Needs a clearer review of wtf is going on.

Note this is a follow-up to r46706 (bug 3311), which snuck in without anybody noticing.

#Comment by PhiLiP (talk | contribs)   10:40, 4 March 2009

what's going wrong with those codes, Brion? Can you be more specified? Thanks.

#Comment by Brion VIBBER (talk | contribs)   08:42, 25 March 2009

The calls to findVariantLink() are totally illegible to begin with. Output parameters aren't marked so data flow is unclear, and the boolean parameter has no clear explanation. (Even looking at the doc comments on the function definition -- 'ignore other conditions'?)

Expanding variants within the diff portion seems a bit odd, too. Wouldn't it make more sense to expand them before diffing?

#Comment by Werdna (talk | contribs)   08:45, 25 March 2009

To be fair, the variant code looks like it wasn't added in this revision.

#Comment by Werdna (talk | contribs)   08:44, 25 March 2009

I can't seem to get category redirects in general to work at all locally, with or without this patch.

#Comment by Brion VIBBER (talk | contribs)   08:46, 25 March 2009

Reverted in r48796 pending clarifcation and code cleanup.

Status & tagging log