Index: branches/category-redirects/includes/LinksUpdate.php |
— | — | @@ -128,7 +128,7 @@ |
129 | 129 | $deletionsById = array(); |
130 | 130 | |
131 | 131 | foreach ($categoryDeletes as $title => $sort) { |
132 | | - $deletionsById[ $titles2ids[ $title ] ] = $sort; |
| 132 | + $deletionsById[ $titles2ids[ $title ][0] ] = $sort; |
133 | 133 | } |
134 | 134 | |
135 | 135 | $categoryInserts = array_diff_assoc( $this->mCategories, $existing ); |
— | — | @@ -303,7 +303,7 @@ |
304 | 304 | * adding the new cat_id(s) |
305 | 305 | * |
306 | 306 | * @param Array $new titles to insert |
307 | | - * @param Array $titles2ids map cat_title => cat_id |
| 307 | + * @param Array $titles2ids map cat_title => ( cat_id, cat_redir ) |
308 | 308 | */ |
309 | 309 | function insertNewCategories( $new, &$titles2ids ) { |
310 | 310 | if ( !$new ) |
— | — | @@ -316,11 +316,11 @@ |
317 | 317 | $this->mDb->insert( 'category', $insertRows, __METHOD__, 'IGNORE' ); |
318 | 318 | |
319 | 319 | $res = $this->mDb->select('category', |
320 | | - array( 'cat_title', 'cat_id' ), |
| 320 | + array( 'cat_title', 'cat_id', 'cat_redir' ), |
321 | 321 | array( 'cat_title' => $new ), |
322 | 322 | __METHOD__, $this->mOptions); |
323 | 323 | while ( $row = $this->mDb->fetchObject( $res ) ) { |
324 | | - $titles2ids[$row->cat_title] = $row->cat_id; |
| 324 | + $titles2ids[$row->cat_title] = array( $row->cat_id, $row->cat_redir ) ; |
325 | 325 | } |
326 | 326 | $this->mDb->freeResult( $res ); |
327 | 327 | } |
— | — | @@ -482,12 +482,13 @@ |
483 | 483 | $diffs = array_diff_assoc( $this->mCategories, $existing ); |
484 | 484 | $arr = array(); |
485 | 485 | foreach ( $diffs as $name => $sortkey ) { |
486 | | - $id = $titles2ids[$name]; |
487 | | - |
| 486 | + list( $inline, $target ) = $titles2ids[$name]; |
| 487 | + if ( $target == null ) |
| 488 | + $target = $inline; |
488 | 489 | $arr[] = array( |
489 | 490 | 'cl_from' => $this->mId, |
490 | | - 'cl_inline' => $id, |
491 | | - 'cl_target' => $id, |
| 491 | + 'cl_inline' => $inline, |
| 492 | + 'cl_target' => $target, |
492 | 493 | 'cl_sortkey' => $sortkey, |
493 | 494 | 'cl_timestamp' => $this->mDb->timestamp() |
494 | 495 | ); |
— | — | @@ -676,7 +677,7 @@ |
677 | 678 | |
678 | 679 | /** |
679 | 680 | * Get an array of existing categories, with the name in the key and sort key in the value, and |
680 | | - * an array (cat_title => cat_id) for existing categories. |
| 681 | + * an array (cat_title => (cat_id, cat_redir)) for existing categories. |
681 | 682 | * |
682 | 683 | * @returns array($existing, $titles2ids) |
683 | 684 | * |
— | — | @@ -685,13 +686,13 @@ |
686 | 687 | function getExistingCategories() { |
687 | 688 | $titles2ids = array(); |
688 | 689 | $res = $this->mDb->select( array( 'categorylinks', 'category' ), |
689 | | - array( 'cat_title', 'cat_id', 'cl_sortkey' ), |
| 690 | + array( 'cat_title', 'cat_id', 'cat_redir', 'cl_sortkey' ), |
690 | 691 | array( 'cl_from' => $this->mId, 'cl_inline=cat_id' ), |
691 | 692 | __METHOD__, $this->mOptions ); |
692 | 693 | $arr = array(); |
693 | 694 | while ( $row = $this->mDb->fetchObject( $res ) ) { |
694 | 695 | $arr[$row->cat_title] = $row->cl_sortkey; |
695 | | - $titles2ids[$row->cat_title] = $row->cat_id; |
| 696 | + $titles2ids[$row->cat_title] = array( $row->cat_id, $row->cat_redir ); |
696 | 697 | } |
697 | 698 | $this->mDb->freeResult( $res ); |
698 | 699 | return array( $arr, $titles2ids ); |