From 36c375f766c933fc6486fd8c8c69d42115f2e025 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sat, 6 Oct 2012 11:54:50 +0200 Subject: [PATCH] pass user object for delete/undelete/filerevert in api/gui Change-Id: Idd214fa1ad9d05ebb2a79225256fb344a1085e9d --- includes/actions/RevertAction.php | 2 +- includes/api/ApiDelete.php | 2 +- includes/api/ApiFileRevert.php | 2 +- includes/api/ApiUndelete.php | 8 +++++++- includes/specials/SpecialUndelete.php | 3 +-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/includes/actions/RevertAction.php b/includes/actions/RevertAction.php index 774343842a..1fc7e90752 100644 --- a/includes/actions/RevertAction.php +++ b/includes/actions/RevertAction.php @@ -115,7 +115,7 @@ class RevertFileAction extends FormAction { $source = $this->page->getFile()->getArchiveVirtualUrl( $this->getRequest()->getText( 'oldimage' ) ); $comment = $data['comment']; // TODO: Preserve file properties from database instead of reloading from file - return $this->page->getFile()->upload( $source, $comment, $comment ); + return $this->page->getFile()->upload( $source, $comment, $comment, 0, false, false, $this->getUser() ); } public function onSuccess() { diff --git a/includes/api/ApiDelete.php b/includes/api/ApiDelete.php index db4e931f4d..964e0ae40b 100644 --- a/includes/api/ApiDelete.php +++ b/includes/api/ApiDelete.php @@ -164,7 +164,7 @@ class ApiDelete extends ApiBase { if ( is_null( $reason ) ) { // Log and RC don't like null reasons $reason = ''; } - return FileDeleteForm::doDelete( $title, $file, $oldimage, $reason, $suppress ); + return FileDeleteForm::doDelete( $title, $file, $oldimage, $reason, $suppress, $user ); } public function mustBePosted() { diff --git a/includes/api/ApiFileRevert.php b/includes/api/ApiFileRevert.php index 83d078d2af..092b0036f2 100644 --- a/includes/api/ApiFileRevert.php +++ b/includes/api/ApiFileRevert.php @@ -50,7 +50,7 @@ class ApiFileRevert extends ApiBase { $this->checkPermissions( $this->getUser() ); $sourceUrl = $this->file->getArchiveVirtualUrl( $this->archiveName ); - $status = $this->file->upload( $sourceUrl, $this->params['comment'], $this->params['comment'] ); + $status = $this->file->upload( $sourceUrl, $this->params['comment'], $this->params['comment'], 0, false, false, $this->getUser() ); if ( $status->isGood() ) { $result = array( 'result' => 'Success' ); diff --git a/includes/api/ApiUndelete.php b/includes/api/ApiUndelete.php index c9962517e2..2ee86411c4 100644 --- a/includes/api/ApiUndelete.php +++ b/includes/api/ApiUndelete.php @@ -61,7 +61,13 @@ class ApiUndelete extends ApiBase { } $pa = new PageArchive( $titleObj ); - $retval = $pa->undelete( ( isset( $params['timestamps'] ) ? $params['timestamps'] : array() ), $params['reason'] ); + $retval = $pa->undelete( + ( isset( $params['timestamps'] ) ? $params['timestamps'] : array() ), + $params['reason'], + array(), + false, + $this->getUser() + ); if ( !is_array( $retval ) ) { $this->dieUsageMsg( 'cannotundelete' ); } diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index 6ebaed5ace..9e945ea021 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -329,8 +329,6 @@ class PageArchive { * on success, false on failure */ function undelete( $timestamps, $comment = '', $fileVersions = array(), $unsuppress = false, User $user = null ) { - global $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 ); @@ -379,6 +377,7 @@ class PageArchive { } if ( $user === null ) { + global $wgUser; $user = $wgUser; } -- 2.20.1