From 40a21ab2b8f3c88efda377aa9fd04df7df718d64 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Fri, 30 Jan 2015 21:06:07 +0100 Subject: [PATCH] Pass user to FileRepo::getUploadStash This avoids use of $wgUser in UploadStash Change-Id: I82ca69818317508109b4d5f4823a20de47f29b01 --- includes/api/ApiQueryStashImageInfo.php | 2 +- includes/api/ApiUpload.php | 2 +- includes/jobqueue/jobs/UploadFromUrlJob.php | 2 +- includes/specials/SpecialUpload.php | 2 +- includes/specials/SpecialUploadStash.php | 7 ++++--- includes/upload/UploadFromChunks.php | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/includes/api/ApiQueryStashImageInfo.php b/includes/api/ApiQueryStashImageInfo.php index 1debb2e14c..59fe8adf99 100644 --- a/includes/api/ApiQueryStashImageInfo.php +++ b/includes/api/ApiQueryStashImageInfo.php @@ -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 ); diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index d6ad7f382d..62d8882898 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -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' ); diff --git a/includes/jobqueue/jobs/UploadFromUrlJob.php b/includes/jobqueue/jobs/UploadFromUrlJob.php index a09db15ab9..d15fd0257b 100644 --- a/includes/jobqueue/jobs/UploadFromUrlJob.php +++ b/includes/jobqueue/jobs/UploadFromUrlJob.php @@ -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. diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index 1b85ff8f57..ce8192b1f7 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -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 ) { diff --git a/includes/specials/SpecialUploadStash.php b/includes/specials/SpecialUploadStash.php index ddb435d95b..462dbee833 100644 --- a/includes/specials/SpecialUploadStash.php +++ b/includes/specials/SpecialUploadStash.php @@ -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() ) { diff --git a/includes/upload/UploadFromChunks.php b/includes/upload/UploadFromChunks.php index 14993023df..8e6c9c6061 100644 --- a/includes/upload/UploadFromChunks.php +++ b/includes/upload/UploadFromChunks.php @@ -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(); -- 2.20.1