Index: maintenance/language/messages.inc =================================================================== --- maintenance/language/messages.inc (revision 18862) +++ maintenance/language/messages.inc (working copy) @@ -1250,7 +1250,7 @@ 'move-watch', 'movepagebtn', 'pagemovedsub', - 'pagemovedtext', + 'pagemoved', 'articleexists', 'talkexists', 'movedto', Index: includes/Article.php =================================================================== --- includes/Article.php (revision 18861) +++ includes/Article.php (working copy) @@ -2216,6 +2216,18 @@ $u = new LinksUpdate( $this->mTitle, $poutput ); $u->doUpdate(); + # Update categorylinks to a category when it becomes a redirect + if ( $this->mTitle->getNamespace() == NS_CATEGORY ) { + $rt = Title::newFromRedirect( $text ); + if( is_object( $rt ) && $rt->getNamespace() == NS_CATEGORY ) { + $dbw =& wfGetDB( DB_MASTER ); + $categorylinks = $dbw->tableName( 'categorylinks' ); + $sql = "UPDATE $categorylinks SET cl_to=" . $dbw->addQuotes( $rt->getDBkey() ) . + " WHERE cl_to=" . $dbw->addQuotes( $this->mTitle->getDbKey() ); + $dbw->query( $sql, __METHOD__ ); + } + } + if ( wfRunHooks( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) { wfSeedRandom(); if ( 0 == mt_rand( 0, 999 ) ) { Index: includes/Parser.php =================================================================== --- includes/Parser.php (revision 18861) +++ includes/Parser.php (working copy) @@ -1757,6 +1757,17 @@ wfProfileIn( "$fname-category" ); $s = rtrim($s . "\n"); # bug 87 + # Redirect categories - bug 3311 + $dbr =& wfGetDB( DB_SLAVE ); + $obj = $dbr->selectRow( array( 'redirect' ), + array( 'rd_namespace', 'rd_title' ), + array( 'rd_from' => $nt->getArticleID() ), + __METHOD__ ); + if ( $obj && $obj->rd_namespace == NS_CATEGORY ) { + # The category redirects to another category; follow it + $nt = Title::makeTitle( NS_CATEGORY, $obj->rd_title ); + } + if ( $wasblank ) { $sortkey = $this->getDefaultSort(); } else { Index: includes/SpecialMovepage.php =================================================================== --- includes/SpecialMovepage.php (revision 18861) +++ includes/SpecialMovepage.php (working copy) @@ -283,7 +283,7 @@ $newText = wfEscapeWikiText( $wgRequest->getVal('newtitle') ); $talkmoved = $wgRequest->getVal('talkmoved'); - $text = wfMsg( 'pagemovedtext', $oldText, $newText ); + $text = wfMsg( 'pagemoved', $oldText, $newText ); $allowHTML = $wgRawHtml; $wgRawHtml = false; Index: includes/Title.php =================================================================== --- includes/Title.php (revision 18861) +++ includes/Title.php (working copy) @@ -1931,6 +1931,13 @@ " AND cl_sortkey=" . $dbw->addQuotes( $this->getPrefixedText() ); $dbw->query( $sql, 'SpecialMovepage::doSubmit' ); + # Fixing links to the old category when moving categories + if ( $this->getNamespace() == NS_CATEGORY && $nt->getNamespace() == NS_CATEGORY ) { + $sql = "UPDATE $categorylinks SET cl_to=" . $dbw->addQuotes( $nt->getDBkey() ) . + " WHERE cl_to=" . $dbw->addQuotes( $this->getDbKey() ); + $dbw->query( $sql, __METHOD__ ); + } + # Update watchlists $oldnamespace = $this->getNamespace() & ~1; @@ -2020,7 +2027,11 @@ # Recreate the redirect, this time in the other direction. $mwRedir = MagicWord::get( 'redirect' ); - $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n"; + if ( $nt->getNamespace() == NS_IMAGE || $nt->getNamespace() == NS_CATEGORY ) { + $redirectText = $mwRedir->getSynonym( 0 ) . ' [[:' . $nt->getPrefixedText() . "]]\n"; + } else { + $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n"; + } $redirectArticle = new Article( $this ); $newid = $redirectArticle->insertOn( $dbw ); $redirectRevision = new Revision( array( @@ -2092,7 +2103,11 @@ # Insert redirect $mwRedir = MagicWord::get( 'redirect' ); - $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n"; + if ( $nt->getNamespace() == NS_IMAGE || $nt->getNamespace() == NS_CATEGORY ) { + $redirectText = $mwRedir->getSynonym( 0 ) . ' [[:' . $nt->getPrefixedText() . "]]\n"; + } else { + $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n"; + } $redirectArticle = new Article( $this ); $newid = $redirectArticle->insertOn( $dbw ); $redirectRevision = new Revision( array( Index: includes/Namespace.php =================================================================== --- includes/Namespace.php (revision 18861) +++ includes/Namespace.php (working copy) @@ -50,7 +50,7 @@ * @return bool */ static function isMovable( $index ) { - return !( $index < NS_MAIN || $index == NS_IMAGE || $index == NS_CATEGORY ); + return !( $index < NS_MAIN || $index == NS_IMAGE ); } /** Index: languages/messages/MessagesEn.php =================================================================== --- languages/messages/MessagesEn.php (revision 18861) +++ languages/messages/MessagesEn.php (working copy) @@ -1959,7 +1959,7 @@ 'move-watch' => 'Watch this page', 'movepagebtn' => 'Move page', 'pagemovedsub' => 'Move succeeded', -'pagemovedtext' => "Page \"[[$1]]\" moved to \"[[$2]]\".", +'pagemoved' => "Page \"[[:$1]]\" moved to \"[[:$2]]\".", 'articleexists' => 'A page of that name already exists, or the name you have chosen is not valid. Please choose another name.', Index: languages/messages/MessagesHe.php =================================================================== --- languages/messages/MessagesHe.php (revision 18862) +++ languages/messages/MessagesHe.php (working copy) @@ -1527,7 +1527,7 @@ 'move-watch' => 'מעקב אחרי דף זה', 'movepagebtn' => 'העבר דף', 'pagemovedsub' => 'ההעברה הושלמה בהצלחה', -'pagemovedtext' => 'הדף "[[$1]]" הועבר לשם "[[$2]]".', +'pagemoved' => 'הדף "[[:$1]]" הועבר לשם "[[:$2]]".', 'articleexists' => 'קיים כבר דף עם אותו שם, או שהשם שבחרתם אינו חוקי. אנא בחרו שם אחר.', 'talkexists' => 'הדף עצמו הועבר בהצלחה, אבל דף השיחה לא הועבר כיוון שקיים כבר דף שיחה במיקום החדש. אנא מזגו אותם ידנית.',