From aa54c12922ee4b0e7845467caca5a899f14017a1 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Mon, 2 Jul 2012 20:33:08 +0200 Subject: [PATCH] Use LogEntry to add new undeletion log entries. * Group global declaration at the top of the function * Pass the user doing the undeletion to PageArchive::undelete() Change-Id: Ieba7d1c277e6faf2b2ff11479b1f4a930916e79c --- includes/specials/SpecialUndelete.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index 79c051a215..908cc1fb5d 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -321,11 +321,14 @@ class PageArchive { * @param $comment String * @param $fileVersions Array * @param $unsuppress Boolean + * @param $user User doing the action, or null to use $wgUser * * @return array(number of file revisions restored, number of image revisions restored, log message) * on success, false on failure */ - function undelete( $timestamps, $comment = '', $fileVersions = array(), $unsuppress = false ) { + function undelete( $timestamps, $comment = '', $fileVersions = array(), $unsuppress = false, User $user = null ) { + global $wgContLang, $wgUser; + // If both the set of text revisions and file revisions are empty, // restore everything. Otherwise, just restore the requested items. $restoreAll = empty( $timestamps ) && empty( $fileVersions ); @@ -354,8 +357,6 @@ class PageArchive { } // Touch the log! - global $wgContLang; - $log = new LogPage( 'delete' ); if( $textRestored && $filesRestored ) { $reason = wfMsgExt( 'undeletedrevisions-files', array( 'content', 'parsemag' ), @@ -375,7 +376,17 @@ class PageArchive { if( trim( $comment ) != '' ) { $reason .= wfMsgForContent( 'colon-separator' ) . $comment; } - $log->addEntry( 'restore', $this->title, $reason ); + + if ( $user === null ) { + $user = $wgUser; + } + + $logEntry = new ManualLogEntry( 'delete', 'restore' ); + $logEntry->setPerformer( $user ); + $logEntry->setTarget( $this->title ); + $logEntry->setComment( $reason ); + $logid = $logEntry->insert(); + $logEntry->publish( $logid ); return array( $textRestored, $filesRestored, $reason ); } @@ -1387,7 +1398,9 @@ class SpecialUndelete extends SpecialPage { $this->mTargetTimestamp, $this->mComment, $this->mFileVersions, - $this->mUnsuppress ); + $this->mUnsuppress, + $this->getUser() + ); if( is_array( $ok ) ) { if ( $ok[1] ) { // Undeleted file count -- 2.20.1