From 5b05dc6951468387c60ef93bfe86cc3e2d58f474 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 3 Aug 2010 20:50:38 +0000 Subject: [PATCH] Fix page moves with new category sort scheme Some other things might have to be updated, like the API and extensions. --- includes/Title.php | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index b2718197b6..e3760779cf 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -3026,6 +3026,8 @@ class Title { * @return \type{\mixed} true on success, getUserPermissionsErrors()-like array on failure */ public function moveTo( &$nt, $auth = true, $reason = '', $createRedirect = true ) { + global $wgContLang; + $err = $this->isValidMoveOperation( $nt, $auth, $reason ); if ( is_array( $err ) ) { return $err; @@ -3058,24 +3060,19 @@ class Title { } $redirid = $this->getArticleID(); - // Category memberships include a sort key which may be customized. - // If it's left as the default (the page title), we need to update - // the sort key to match the new title. - // - // Be careful to avoid resetting cl_timestamp, which may disturb - // time-based lists on some sites. - // - // Warning -- if the sort key is *explicitly* set to the old title, - // we can't actually distinguish it from a default here, and it'll - // be set to the new title even though it really shouldn't. - // It'll get corrected on the next edit, but resetting cl_timestamp. + // 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( + 'categorylinks', + 'cl_sortkey_prefix', + array( 'cl_from' => $pageid ), + __METHOD__ + ); $dbw->update( 'categorylinks', array( - 'cl_sortkey' => $nt->getPrefixedText(), + 'cl_sortkey' => $wgContLang->convertToSortkey( $nt->getCategorySortkey( $prefix ) ), 'cl_timestamp=cl_timestamp' ), - array( - 'cl_from' => $pageid, - 'cl_sortkey' => $this->getPrefixedText() ), + array( 'cl_from' => $pageid ), __METHOD__ ); if ( $protected ) { -- 2.20.1