Make the UploadStash repo specific by creating FileRepo::getUploadStash(). In practic...
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Tue, 25 Jan 2011 21:26:53 +0000 (21:26 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Tue, 25 Jan 2011 21:26:53 +0000 (21:26 +0000)
includes/api/ApiQueryStashImageInfo.php
includes/filerepo/FileRepo.php
includes/specials/SpecialUpload.php
includes/specials/SpecialUploadStash.php
includes/upload/UploadBase.php
includes/upload/UploadStash.php

index 73bad15..bcd8196 100644 (file)
@@ -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 );
index a3931f2..386274a 100644 (file)
@@ -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 );
+       }
 }
index f239edf..b0de13e 100644 (file)
@@ -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 ) {
index 58b174f..2f0335b 100644 (file)
@@ -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;
                }
index 25a2b9d..b48cecb 100644 (file)
@@ -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(),
index 1a13859..8dd2c76 100644 (file)
@@ -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' );