Do not lose message parameters in UploadFromChunks::verifyChunk()
authorBartosz Dziewoński <matma.rex@gmail.com>
Tue, 13 Dec 2016 14:11:43 +0000 (15:11 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Tue, 13 Dec 2016 15:11:03 +0000 (15:11 +0000)
This code is gross, and my changes do not really make it better,
but it works more correctly more often.

Bug: T147720
Change-Id: If9ce05045ada1e3f55e031639e4c4ebc2a216de8

includes/upload/UploadFromChunks.php

index 08cf434..449fc05 100644 (file)
@@ -222,7 +222,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() ) {
@@ -364,7 +364,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 +376,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() );
+       }
 }