Index: trunk/phase3/includes/LinksUpdate.php |
— | — | @@ -427,18 +427,25 @@ |
428 | 428 | function getCategoryInsertions( $existing = array() ) { |
429 | 429 | global $wgContLang; |
430 | 430 | $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 ); |
435 | 435 | // for category redirection |
436 | 436 | if ( $nt->isRedirect() ) { |
437 | 437 | $at = new Article( $nt ); |
438 | 438 | $nt = $at->getRedirectTarget(); |
| 439 | + $newname = $nt->getText(); |
439 | 440 | // 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; |
442 | 444 | } |
| 445 | + } |
| 446 | + $arr = array(); |
| 447 | + foreach ( $diffs as $name => $sortkey ) { |
| 448 | + $nt = Title::makeTitleSafe( NS_CATEGORY, $name ); |
| 449 | + $wgContLang->findVariantLink( $name, $nt, true ); |
443 | 450 | $arr[] = array( |
444 | 451 | 'cl_from' => $this->mId, |
445 | 452 | 'cl_to' => $name, |