From: Ian Baker Date: Thu, 18 Aug 2011 23:36:24 +0000 (+0000) Subject: Two bugs: X-Git-Tag: 1.31.0-rc.0~28180 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=000080990d792ad3522ac48571793c0c28a1b1ac;p=lhc%2Fweb%2Fwiklou.git 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 --- 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; } /**