Pass user to FileRepo::getUploadStash
authorumherirrender <umherirrender_de.wp@web.de>
Fri, 30 Jan 2015 20:06:07 +0000 (21:06 +0100)
committerumherirrender <umherirrender_de.wp@web.de>
Sat, 31 Jan 2015 20:46:05 +0000 (21:46 +0100)
This avoids use of $wgUser in UploadStash

Change-Id: I82ca69818317508109b4d5f4823a20de47f29b01

includes/api/ApiQueryStashImageInfo.php
includes/api/ApiUpload.php
includes/jobqueue/jobs/UploadFromUrlJob.php
includes/specials/SpecialUpload.php
includes/specials/SpecialUploadStash.php
includes/upload/UploadFromChunks.php

index 1debb2e..59fe8ad 100644 (file)
@@ -52,7 +52,7 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo {
                }
 
                try {
-                       $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash();
+                       $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash( $this->getUser() );
 
                        foreach ( $params['filekey'] as $filekey ) {
                                $file = $stash->getFile( $filekey );
index d6ad7f3..62d8882 100644 (file)
@@ -277,7 +277,7 @@ class ApiUpload extends ApiBase {
         */
        private function performStash() {
                try {
-                       $stashFile = $this->mUpload->stashFile();
+                       $stashFile = $this->mUpload->stashFile( $this->getUser() );
 
                        if ( !$stashFile ) {
                                throw new MWException( 'Invalid stashed file' );
index a09db15..d15fd02 100644 (file)
@@ -81,7 +81,7 @@ class UploadFromUrlJob extends Job {
                        if ( $warnings ) {
 
                                # Stash the upload
-                               $key = $this->upload->stashFile();
+                               $key = $this->upload->stashFile( $this->user );
 
                                // @todo FIXME: This has been broken for a while.
                                // User::leaveUserMessage() does not exist.
index 1b85ff8..ce8192b 100644 (file)
@@ -985,7 +985,7 @@ class UploadForm extends HTMLForm {
        protected function getDescriptionSection() {
                $config = $this->getConfig();
                if ( $this->mSessionKey ) {
-                       $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash();
+                       $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash( $this->getUser() );
                        try {
                                $file = $stash->getFile( $this->mSessionKey );
                        } catch ( Exception $e ) {
index ddb435d..462dbee 100644 (file)
@@ -49,7 +49,7 @@ class SpecialUploadStash extends UnlistedSpecialPage {
        public function __construct() {
                parent::__construct( 'UploadStash', 'upload' );
                try {
-                       $this->stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash();
+                       $this->stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash( $this->getUser() );
                } catch ( UploadStashNotAvailableException $e ) {
                }
        }
@@ -331,11 +331,12 @@ class SpecialUploadStash extends UnlistedSpecialPage {
         * This works, because there really is only one stash per logged-in user, despite appearances.
         *
         * @param array $formData
+        * @param HTMLForm $form
         * @return Status
         */
-       public static function tryClearStashedUploads( $formData ) {
+       public static function tryClearStashedUploads( $formData, $form ) {
                if ( isset( $formData['Clear'] ) ) {
-                       $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash();
+                       $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash( $form->getUser() );
                        wfDebug( 'stash has: ' . print_r( $stash->listFiles(), true ) . "\n" );
 
                        if ( !$stash->clear() ) {
index 1499302..8e6c9c6 100644 (file)
@@ -77,7 +77,7 @@ class UploadFromChunks extends UploadFromFile {
 
                $this->verifyChunk();
                // Create a local stash target
-               $this->mLocalFile = parent::stashFile();
+               $this->mLocalFile = parent::stashFile( $user );
                // Update the initial file offset (based on file size)
                $this->mOffset = $this->mLocalFile->getSize();
                $this->mFileKey = $this->mLocalFile->getFileKey();