From 7b82b3fd242e772f9b2332bd0a8590928b69e64e Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Mon, 14 Mar 2011 02:19:28 +0000 Subject: [PATCH] (bug 28020) Moving pages causes the cl_sortkey thats appropriate for one of the categorylinks, to be set for all of them. But the cl_sortkey_prefix are kept to the right value for the cl_sortkey's that are set to the wrong value, totally messing things up. End result is: Have a page, with some categories having different sortkeys, move that page, now all the categories have the same sortkey, but still have their original prefix, so linksupdate things the sortkey is correct. End result is null edits don't fix the sortkey, nothing but removing and re-adding category will reset sortkey to correct value. --- includes/Title.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index a48cbae700..635c75900d 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -3111,19 +3111,26 @@ class Title { // Refresh the sortkey for this row. Be careful to avoid resetting // cl_timestamp, which may disturb time-based lists on some sites. - $prefix = $dbw->selectField( + $prefixes = $dbw->select( 'categorylinks', - 'cl_sortkey_prefix', + array( 'cl_sortkey_prefix', 'cl_to' ), array( 'cl_from' => $pageid ), __METHOD__ ); - $dbw->update( 'categorylinks', - array( - 'cl_sortkey' => Collation::singleton()->getSortKey( - $nt->getCategorySortkey( $prefix ) ), - 'cl_timestamp=cl_timestamp' ), - array( 'cl_from' => $pageid ), - __METHOD__ ); + foreach ( $prefixes as $prefixRow ) { + $prefix = $prefixRow->cl_sortkey_prefix; + $catTo = $prefixRow->cl_to; + $dbw->update( 'categorylinks', + array( + 'cl_sortkey' => Collation::singleton()->getSortKey( + $nt->getCategorySortkey( $prefix ) ), + 'cl_timestamp=cl_timestamp' ), + array( + 'cl_from' => $pageid, + 'cl_to' => $catTo ), + __METHOD__ + ); + } if ( $protected ) { # Protect the redirect title as the title used to be... -- 2.20.1