From: Alexandre Emsenhuber Date: Mon, 2 Jul 2012 18:33:08 +0000 (+0200) Subject: Use LogEntry to add new undeletion log entries. X-Git-Tag: 1.31.0-rc.0~23166^2 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_del%27%2C%20idvote=vote.voteid%29%20%7D%7D?a=commitdiff_plain;h=aa54c12922ee4b0e7845467caca5a899f14017a1;p=lhc%2Fweb%2Fwiklou.git 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 --- 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