From 425b9410ade6349facabbaad8baf9dbd8d7195b9 Mon Sep 17 00:00:00 2001 From: Michael Dale Date: Thu, 8 Oct 2009 22:30:04 +0000 Subject: [PATCH] * bug 21063 http copy upload and upload from stash give different file path types. call "getRealPath" to go from virtual -> real if necessary --- includes/upload/UploadBase.php | 13 +++++++++++++ includes/upload/UploadFromChunks.php | 12 ------------ includes/upload/UploadFromStash.php | 21 ++++++++++----------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index 3a6b7e54ee..700338f8b5 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -137,6 +137,19 @@ abstract class UploadBase { return empty( $this->mFileSize ); } + /* + * getRealPath + * @param string $srcPath the source path + * @returns the real path if it was a virtual url + */ + function getRealPath( $srcPath ){ + $repo = RepoGroup::singleton()->getLocalRepo(); + if ( $repo->isVirtualUrl( $srcPath ) ) { + return $repo->resolveVirtualUrl( $srcPath ); + } + return $srcPath; + } + /** * Verify whether the upload is sane. * Returns self::OK or else an array with error information diff --git a/includes/upload/UploadFromChunks.php b/includes/upload/UploadFromChunks.php index fa7f4ab7bd..1167243372 100644 --- a/includes/upload/UploadFromChunks.php +++ b/includes/upload/UploadFromChunks.php @@ -105,18 +105,6 @@ class UploadFromChunks extends UploadBase { return true; } } - /* - * getRealPath - * @param string $srcPath the source path - * @returns the real path if it was a virtual url - */ - function getRealPath( $srcPath ){ - $repo = RepoGroup::singleton()->getLocalRepo(); - if ( $repo->isVirtualUrl( $srcPath ) ) { - return $repo->resolveVirtualUrl( $srcPath ); - } - return $srcPath; - } // pretty ugly inter-mixing of mParam and local vars function setupChunkSession( $summary, $comment, $watch ) { diff --git a/includes/upload/UploadFromStash.php b/includes/upload/UploadFromStash.php index 43ef2a34c7..6fbeb519ca 100644 --- a/includes/upload/UploadFromStash.php +++ b/includes/upload/UploadFromStash.php @@ -2,24 +2,24 @@ /** * @file * @ingroup upload - * + * * Implements uploading from previously stored file. - * + * * @author Bryan Tong Minh */ - + class UploadFromStash extends UploadBase { public static function isValidSessionKey( $key, $sessionData ) { - return !empty( $key ) && - is_array( $sessionData ) && - isset( $sessionData[$key] ) && - isset( $sessionData[$key]['version'] ) && + return !empty( $key ) && + is_array( $sessionData ) && + isset( $sessionData[$key] ) && + isset( $sessionData[$key]['version'] ) && $sessionData[$key]['version'] == self::SESSION_VERSION; } public static function isValidRequest( $request ) { $sessionData = $request->getSessionData( 'wsUploadData' ); - return self::isValidSessionKey( + return self::isValidSessionKey( $request->getInt( 'wpSessionKey' ), $sessionData ); @@ -34,10 +34,9 @@ class UploadFromStash extends UploadBase { * them in the session on the server and just give * an opaque key to the user agent. */ - - $repo = RepoGroup::singleton()->getLocalRepo(); + parent::initialize( $name, - $repo->resolveVirtualUrl( $sessionData['mTempPath'] ), + $this->getRealPath ( $sessionData['mTempPath'] ), $sessionData['mFileSize'], false ); -- 2.20.1