Merge "Change 'editfont' default preference to 'monospace'"
[lhc/web/wiklou.git] / includes / upload / UploadFromChunks.php
index 08cf434..68bcb9d 100644 (file)
@@ -63,6 +63,52 @@ class UploadFromChunks extends UploadFromFile {
                }
        }
 
+       /**
+        * @inheritDoc
+        */
+       public function tryStashFile( User $user, $isPartial = false ) {
+               try {
+                       $this->verifyChunk();
+               } catch ( UploadChunkVerificationException $e ) {
+                       return Status::newFatal( $e->msg );
+               }
+
+               return parent::tryStashFile( $user, $isPartial );
+       }
+
+       /**
+        * @inheritDoc
+        * @throws UploadChunkVerificationException
+        * @deprecated since 1.28 Use tryStashFile() instead
+        */
+       public function stashFile( User $user = null ) {
+               wfDeprecated( __METHOD__, '1.28' );
+               $this->verifyChunk();
+               return parent::stashFile( $user );
+       }
+
+       /**
+        * @inheritDoc
+        * @throws UploadChunkVerificationException
+        * @deprecated since 1.28
+        */
+       public function stashFileGetKey() {
+               wfDeprecated( __METHOD__, '1.28' );
+               $this->verifyChunk();
+               return parent::stashFileGetKey();
+       }
+
+       /**
+        * @inheritDoc
+        * @throws UploadChunkVerificationException
+        * @deprecated since 1.28
+        */
+       public function stashSession() {
+               wfDeprecated( __METHOD__, '1.28' );
+               $this->verifyChunk();
+               return parent::stashSession();
+       }
+
        /**
         * Calls the parent doStashFile and updates the uploadsession table to handle "chunks"
         *
@@ -74,7 +120,6 @@ class UploadFromChunks extends UploadFromFile {
                $this->mChunkIndex = 0;
                $this->mOffset = 0;
 
-               $this->verifyChunk();
                // Create a local stash target
                $this->mStashFile = parent::doStashFile( $user );
                // Update the initial file offset (based on file size)
@@ -113,7 +158,7 @@ class UploadFromChunks extends UploadFromFile {
 
        /**
         * Append the final chunk and ready file for parent::performUpload()
-        * @return FileRepoStatus
+        * @return Status
         */
        public function concatenateChunks() {
                $chunkIndex = $this->getChunkIndex();
@@ -222,7 +267,7 @@ class UploadFromChunks extends UploadFromFile {
                                        $this->verifyChunk();
                                        $this->mTempPath = $oldTemp;
                                } catch ( UploadChunkVerificationException $e ) {
-                                       return Status::newFatal( $e->getMessage() );
+                                       return Status::newFatal( $e->msg );
                                }
                                $status = $this->outputChunk( $chunkPath );
                                if ( $status->isGood() ) {
@@ -313,7 +358,7 @@ class UploadFromChunks extends UploadFromFile {
         *
         * @param string $chunkPath
         * @throws UploadChunkFileException
-        * @return FileRepoStatus
+        * @return Status
         */
        private function outputChunk( $chunkPath ) {
                // Key is fileKey + chunk index
@@ -364,7 +409,7 @@ class UploadFromChunks extends UploadFromFile {
                $this->mDesiredDestName = $oldDesiredDestName;
                $this->mTitle = false;
                if ( is_array( $res ) ) {
-                       throw new UploadChunkVerificationException( $res[0] );
+                       throw new UploadChunkVerificationException( $res );
                }
        }
 }
@@ -376,4 +421,10 @@ class UploadChunkFileException extends MWException {
 }
 
 class UploadChunkVerificationException extends MWException {
+       public $msg;
+       public function __construct( $res ) {
+               $this->msg = call_user_func_array( 'wfMessage', $res );
+               parent::__construct( call_user_func_array( 'wfMessage', $res )
+                       ->inLanguage( 'en' )->useDatabase( false )->text() );
+       }
 }