From: Bartosz Dziewoński Date: Sat, 6 Sep 2014 15:17:20 +0000 (+0200) Subject: Update categorylinks.cl_type when moving a page X-Git-Tag: 1.31.0-rc.0~14025 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=e0ff770adee0695b94e6c22d9d9007e836374b70;p=lhc%2Fweb%2Fwiklou.git Update categorylinks.cl_type when moving a page cl_type might need to be changed if the page was moved between special-cased namespaces (Category ↔ File ↔ (other)). Also update cl_collation, which also might have changed in the meantime. Bug: 69740 Change-Id: I46032a8ba04d77005731c02680f77a8808974087 --- diff --git a/includes/Title.php b/includes/Title.php index ca292eefcf..7959860f9b 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -3748,7 +3748,7 @@ class Title { * @return array|bool True on success, getUserPermissionsErrors()-like array on failure */ public function moveTo( &$nt, $auth = true, $reason = '', $createRedirect = true ) { - global $wgUser; + global $wgUser, $wgCategoryCollation; $err = $this->isValidMoveOperation( $nt, $auth, $reason ); if ( is_array( $err ) ) { // Auto-block user's IP if the account was "hard" blocked @@ -3787,12 +3787,21 @@ class Title { // Refresh the sortkey for this row. Be careful to avoid resetting // cl_timestamp, which may disturb time-based lists on some sites. + // @todo This block should be killed, it's duplicating code + // from LinksUpdate::getCategoryInsertions() and friends. $prefixes = $dbw->select( 'categorylinks', array( 'cl_sortkey_prefix', 'cl_to' ), array( 'cl_from' => $pageid ), __METHOD__ ); + if ( $nt->getNamespace() == NS_CATEGORY ) { + $type = 'subcat'; + } elseif ( $nt->getNamespace() == NS_FILE ) { + $type = 'file'; + } else { + $type = 'page'; + } foreach ( $prefixes as $prefixRow ) { $prefix = $prefixRow->cl_sortkey_prefix; $catTo = $prefixRow->cl_to; @@ -3800,6 +3809,8 @@ class Title { array( 'cl_sortkey' => Collation::singleton()->getSortKey( $nt->getCategorySortkey( $prefix ) ), + 'cl_collation' => $wgCategoryCollation, + 'cl_type' => $type, 'cl_timestamp=cl_timestamp' ), array( 'cl_from' => $pageid,