From: Bryan Tong Minh Date: Tue, 25 Jan 2011 21:26:53 +0000 (+0000) Subject: Make the UploadStash repo specific by creating FileRepo::getUploadStash(). In practic... X-Git-Tag: 1.31.0-rc.0~32358 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/?a=commitdiff_plain;h=9fff147a379cad7afef268a68f465170ece95d67;p=lhc%2Fweb%2Fwiklou.git Make the UploadStash repo specific by creating FileRepo::getUploadStash(). In practice this will probably not be used and makes getting an UploadStash object slightly more type work, but I think it is cleaner to have an upload stash explicitly bound to a repo. --- diff --git a/includes/api/ApiQueryStashImageInfo.php b/includes/api/ApiQueryStashImageInfo.php index 73bad15b4a..bcd8196acc 100644 --- a/includes/api/ApiQueryStashImageInfo.php +++ b/includes/api/ApiQueryStashImageInfo.php @@ -42,7 +42,7 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo { $result = $this->getResult(); try { - $stash = new UploadStash(); + $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash(); foreach ( $params['sessionkey'] as $sessionkey ) { $file = $stash->getFile( $sessionkey ); diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index a3931f2c2f..386274acb2 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -691,4 +691,11 @@ abstract class FileRepo { array_unshift( $args, 'filerepo', $this->getName() ); return call_user_func_array( 'wfMemcKey', $args ); } + + /** + * Get an UploadStash associated with this repo. + */ + function getUploadStash() { + return new UploadStash( $this ); + } } diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index f239edff18..b0de13e1f6 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -939,7 +939,7 @@ class UploadForm extends HTMLForm { global $wgUser; if ( $this->mSessionKey ) { - $stash = new UploadStash; + $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash(); try { $file = $stash->getFile( $this->mSessionKey ); } catch ( MWException $e ) { diff --git a/includes/specials/SpecialUploadStash.php b/includes/specials/SpecialUploadStash.php index 58b174f55c..2f0335b47d 100644 --- a/includes/specials/SpecialUploadStash.php +++ b/includes/specials/SpecialUploadStash.php @@ -41,7 +41,7 @@ class SpecialUploadStash extends UnlistedSpecialPage { parent::__construct( 'UploadStash', 'upload' ); try { - $this->stash = new UploadStash( ); + $this->stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash(); } catch ( UploadStashNotAvailableException $e ) { return null; } diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index 25a2b9d01c..b48cecb144 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -643,7 +643,7 @@ abstract class UploadBase { * @return File: stashed file */ public function stashSessionFile( $key = null ) { - $stash = new UploadStash(); + $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash();; $data = array( 'mFileProps' => $this->mFileProps, 'mSourceType' => $this->getSourceType(), diff --git a/includes/upload/UploadStash.php b/includes/upload/UploadStash.php index 1a13859e3a..8dd2c766c9 100644 --- a/includes/upload/UploadStash.php +++ b/includes/upload/UploadStash.php @@ -31,10 +31,10 @@ class UploadStash { * Represents the session which contains temporarily stored files. * Designed to be compatible with the session stashing code in UploadBase (should replace it eventually) */ - public function __construct() { + public function __construct( $repo ) { // this might change based on wiki's configuration. - $this->repo = RepoGroup::singleton()->getLocalRepo(); + $this->repo = $repo; if ( ! isset( $_SESSION ) ) { throw new UploadStashNotAvailableException( 'no session variable' );