r37113 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37112‎ | r37113 | r37114 >
Date:15:38, 5 July 2008
Author:nicdumz
Status:old
Tags:
Comment:
Now propagating cat_redir into cl_target in LinksUpdate. (but no mechanism is modifying cat_redir yet)
Modified paths:
  • /branches/category-redirects/includes/LinksUpdate.php (modified) (history)

Diff [purge]

Index: branches/category-redirects/includes/LinksUpdate.php
@@ -128,7 +128,7 @@
129129 $deletionsById = array();
130130
131131 foreach ($categoryDeletes as $title => $sort) {
132 - $deletionsById[ $titles2ids[ $title ] ] = $sort;
 132+ $deletionsById[ $titles2ids[ $title ][0] ] = $sort;
133133 }
134134
135135 $categoryInserts = array_diff_assoc( $this->mCategories, $existing );
@@ -303,7 +303,7 @@
304304 * adding the new cat_id(s)
305305 *
306306 * @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 )
308308 */
309309 function insertNewCategories( $new, &$titles2ids ) {
310310 if ( !$new )
@@ -316,11 +316,11 @@
317317 $this->mDb->insert( 'category', $insertRows, __METHOD__, 'IGNORE' );
318318
319319 $res = $this->mDb->select('category',
320 - array( 'cat_title', 'cat_id' ),
 320+ array( 'cat_title', 'cat_id', 'cat_redir' ),
321321 array( 'cat_title' => $new ),
322322 __METHOD__, $this->mOptions);
323323 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 ) ;
325325 }
326326 $this->mDb->freeResult( $res );
327327 }
@@ -482,12 +482,13 @@
483483 $diffs = array_diff_assoc( $this->mCategories, $existing );
484484 $arr = array();
485485 foreach ( $diffs as $name => $sortkey ) {
486 - $id = $titles2ids[$name];
487 -
 486+ list( $inline, $target ) = $titles2ids[$name];
 487+ if ( $target == null )
 488+ $target = $inline;
488489 $arr[] = array(
489490 'cl_from' => $this->mId,
490 - 'cl_inline' => $id,
491 - 'cl_target' => $id,
 491+ 'cl_inline' => $inline,
 492+ 'cl_target' => $target,
492493 'cl_sortkey' => $sortkey,
493494 'cl_timestamp' => $this->mDb->timestamp()
494495 );
@@ -676,7 +677,7 @@
677678
678679 /**
679680 * 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.
681682 *
682683 * @returns array($existing, $titles2ids)
683684 *
@@ -685,13 +686,13 @@
686687 function getExistingCategories() {
687688 $titles2ids = array();
688689 $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' ),
690691 array( 'cl_from' => $this->mId, 'cl_inline=cat_id' ),
691692 __METHOD__, $this->mOptions );
692693 $arr = array();
693694 while ( $row = $this->mDb->fetchObject( $res ) ) {
694695 $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 );
696697 }
697698 $this->mDb->freeResult( $res );
698699 return array( $arr, $titles2ids );

Status & tagging log