pass user object for delete/undelete/filerevert in api/gui
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 6 Oct 2012 09:54:50 +0000 (11:54 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Sat, 6 Oct 2012 09:54:50 +0000 (11:54 +0200)
Change-Id: Idd214fa1ad9d05ebb2a79225256fb344a1085e9d

includes/actions/RevertAction.php
includes/api/ApiDelete.php
includes/api/ApiFileRevert.php
includes/api/ApiUndelete.php
includes/specials/SpecialUndelete.php

index 7743438..1fc7e90 100644 (file)
@@ -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() {
index db4e931..964e0ae 100644 (file)
@@ -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() {
index 83d078d..092b003 100644 (file)
@@ -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' );
index c996251..2ee8641 100644 (file)
@@ -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' );
                }
index 6ebaed5..9e945ea 100644 (file)
@@ -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;
                }