From e7f3210ef39d1e4b71c36fda9b65f6351fe4b12b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Mon, 12 Sep 2011 14:58:41 +0000 Subject: [PATCH] Start producing new style move log entries --- includes/Title.php | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index 1a4456d4fc..557d97f43b 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -3331,11 +3331,28 @@ class Title { private function moveOverExistingRedirect( &$nt, $reason = '', $createRedirect = true ) { global $wgUser, $wgContLang, $wgEnableInterwikiTemplatesTracking, $wgGlobalDatabase; - $moveOverRedirect = $nt->exists(); + if ( $nt->exists() ) { + $moveOverRedirect = true; + $logtype = 'move_redir'; + } else { + $moveOverRedirect = false; + $logType = 'move'; + } + + $redirectSuppressed = !$createRedirect && $wgUser->isAllowed( 'suppressredirect' ); - $commentMsg = ( $moveOverRedirect ? '1movedto2_redir' : '1movedto2' ); - $comment = wfMsgForContent( $commentMsg, $this->getPrefixedText(), $nt->getPrefixedText() ); + $logEntry = new ManualLogEntry( 'move', $logType ); + $logEntry->setPerformer( $wgUser ); + $logEntry->setTarget( $this ); + $logEntry->setComment( $reason ); + $logEntry->setParameters( array( + '4::target' => $nt->getPrefixedText(), + '5::noredir' => $redirectSuppressed ? '1': '0', + ) ); + $formatter = LogFormatter::newFromEntry( $logEntry ); + $formatter->setContext( RequestContext::newExtraneousContext( $this ) ); + $comment = $formatter->getPlainActionText(); if ( $reason ) { $comment .= wfMsgForContent( 'colon-separator' ) . $reason; } @@ -3442,16 +3459,13 @@ class Title { 'pl_title' => $nt->getDBkey() ), __METHOD__ ); } - $redirectSuppressed = false; } else { $this->resetArticleID( 0 ); - $redirectSuppressed = true; } # Log the move - $log = new LogPage( 'move' ); - $logType = ( $moveOverRedirect ? 'move_redir' : 'move' ); - $log->addEntry( $logType, $this, $reason, array( 1 => $nt->getPrefixedText(), 2 => $redirectSuppressed ) ); + $logid = $logEntry->insert(); + $logEntry->publish( $logid ); # Purge caches for old and new titles if ( $moveOverRedirect ) { -- 2.20.1