diff options
author | Ian Baker <raindrift@users.mediawiki.org> | 2011-08-15 18:10:10 +0000 |
---|---|---|
committer | Ian Baker <raindrift@users.mediawiki.org> | 2011-08-15 18:10:10 +0000 |
commit | 9cb2d4743a994012a819153021eb0b7a308b5ead (patch) | |
tree | 60a2e5740a7772f124b24f0e2911b6f31fbe5b2c /includes/upload | |
parent | 08334c06c8def7daddac47a7b1ef9b7a15f87d43 (diff) | |
download | mediawikicore-9cb2d4743a994012a819153021eb0b7a308b5ead.tar.gz mediawikicore-9cb2d4743a994012a819153021eb0b7a308b5ead.zip |
Fixed incorrect usage of || operator, added test
removed spurious use of empty()
listFiles() was broken, now works
followup to r92009
Notes
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/94536
Diffstat (limited to 'includes/upload')
-rw-r--r-- | includes/upload/UploadFromStash.php | 19 | ||||
-rw-r--r-- | includes/upload/UploadStash.php | 2 |
2 files changed, 12 insertions, 9 deletions
diff --git a/includes/upload/UploadFromStash.php b/includes/upload/UploadFromStash.php index a576859357a0..ce0bc8c906ec 100644 --- a/includes/upload/UploadFromStash.php +++ b/includes/upload/UploadFromStash.php @@ -38,7 +38,7 @@ class UploadFromStash extends UploadBase { public static function isValidKey( $key ) { // this is checked in more detail in UploadStash - return preg_match( UploadStash::KEY_FORMAT_REGEX, $key ); + return preg_match( UploadStash::KEY_FORMAT_REGEX, $key ) ? true : false; } /** @@ -47,7 +47,10 @@ class UploadFromStash extends UploadBase { * @return Boolean */ public static function isValidRequest( $request ) { - return self::isValidKey( $request->getText( 'wpFileKey' ) || $request->getText( 'wpSessionKey' ) ); + // this passes wpSessionKey to getText() as a default when wpFileKey isn't set. + // wpSessionKey has no default which guarantees failure if both are missing + // (though that should have been caught earlier) + return self::isValidKey( $request->getText( 'wpFileKey', $request->getText( 'wpSessionKey' ) ) ); } public function initialize( $key, $name = 'upload_file' ) { @@ -74,12 +77,12 @@ class UploadFromStash extends UploadBase { * @param $request WebRequest */ public function initializeFromRequest( &$request ) { - $fileKey = $request->getText( 'wpFileKey' ) || $request->getText( 'wpSessionKey' ); + // sends wpSessionKey as a default when wpFileKey is missing + $fileKey = $request->getText( 'wpFileKey', $request->getText( 'wpSessionKey' ) ); + + // chooses one of wpDestFile, wpUploadFile, filename in that order. + $desiredDestName = $request->getText( 'wpDestFile', $request->getText( 'wpUploadFile', $request->getText( 'filename' ) ) ); - $desiredDestName = $request->getText( 'wpDestFile' ); - if( !$desiredDestName ) { - $desiredDestName = $request->getText( 'wpUploadFile' ) || $request->getText( 'filename' ); - } return $this->initialize( $fileKey, $desiredDestName ); } @@ -100,7 +103,7 @@ class UploadFromStash extends UploadBase { * There is no need to stash the image twice */ public function stashFile( $key = null ) { - if ( !empty( $this->mLocalFile ) ) { + if ( !$this->mLocalFile ) { return $this->mLocalFile; } return parent::stashFile( $key ); diff --git a/includes/upload/UploadStash.php b/includes/upload/UploadStash.php index b46a6fb9c3c6..af02fb21f9ea 100644 --- a/includes/upload/UploadStash.php +++ b/includes/upload/UploadStash.php @@ -416,7 +416,7 @@ class UploadStash { $res = $dbr->select( 'uploadstash', 'us_key', - array( 'us_key' => $key ), + array( 'us_user' => $this->userId ), __METHOD__ ); |