From 000080990d792ad3522ac48571793c0c28a1b1ac Mon Sep 17 00:00:00 2001 From: Ian Baker Date: Thu, 18 Aug 2011 23:36:24 +0000 Subject: [PATCH] Two bugs: 1. When the user isn't passed to UploadFromStash::__construct(), it would break when it shouldn't. 2. When stashing files, sometimes an instance of UnregisteredLocalFile would be returned instead of UploadStashFile --- includes/upload/UploadFromStash.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/includes/upload/UploadFromStash.php b/includes/upload/UploadFromStash.php index 22a92f3ae2..8cb22ce5c9 100644 --- a/includes/upload/UploadFromStash.php +++ b/includes/upload/UploadFromStash.php @@ -29,7 +29,12 @@ class UploadFromStash extends UploadBase { if( $stash ) { $this->stash = $stash; } else { - wfDebug( __METHOD__ . " creating new UploadStash instance for " . $user->getId() . "\n" ); + if( $user ) { + wfDebug( __METHOD__ . " creating new UploadStash instance for " . $user->getId() . "\n" ); + } else { + wfDebug( __METHOD__ . " creating new UploadStash instance with no user\n" ); + } + $this->stash = new UploadStash( $this->repo, $this->user ); } @@ -100,13 +105,13 @@ class UploadFromStash extends UploadBase { } /** - * There is no need to stash the image twice + * Stash the file. */ public function stashFile() { - if ( $this->mLocalFile ) { - return $this->mLocalFile; - } - return parent::stashFile(); + // replace mLocalFile with an instance of UploadStashFile, which adds some methods + // that are useful for stashed files. + $this->mLocalFile = parent::stashFile(); + return $this->mLocalFile; } /** -- 2.20.1