* (bug 12584) Don't reset cl_timestamp when auto-updating sort key on move
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 11 Jan 2008 20:52:54 +0000 (20:52 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 11 Jan 2008 20:52:54 +0000 (20:52 +0000)
Also cleaned up comment and ugly manual query

RELEASE-NOTES
includes/Title.php

index 69b8fe3..5e1e32f 100644 (file)
@@ -296,6 +296,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 12553) Fixed invalid XHTML in edit conflict screen
 * (bug 12505) Fixed section=0 with action=raw
 * Do not log user rights change that didn't change anything
+* (bug 12584) Don't reset cl_timestamp when auto-updating sort key on move
+
 
 == Parser changes in 1.12 ==
 
index 84143cc..da7ccea 100644 (file)
@@ -2350,13 +2350,26 @@ class Title {
                }
                $redirid = $this->getArticleID();
 
-               # Fixing category links (those without piped 'alternate' names) to be sorted under the new title
+               // 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.
                $dbw = wfGetDB( DB_MASTER );
-               $categorylinks = $dbw->tableName( 'categorylinks' );
-               $sql = "UPDATE $categorylinks SET cl_sortkey=" . $dbw->addQuotes( $nt->getPrefixedText() ) .
-                       " WHERE cl_from=" . $dbw->addQuotes( $pageid ) .
-                       " AND cl_sortkey=" . $dbw->addQuotes( $this->getPrefixedText() );
-               $dbw->query( $sql, 'SpecialMovepage::doSubmit' );
+               $dbw->update( 'categorylinks',
+                       array(
+                               'cl_sortkey' => $nt->getPrefixedText(),
+                               'cl_timestamp=cl_timestamp' ),
+                       array(
+                               'cl_from' => $pageid,
+                               'cl_sortkey' => $this->getPrefixedText() ),
+                       __METHOD__ );
 
                # Update watchlists