Merge "Add "mVersion" sanity check to User::loadFromCache()"
[lhc/web/wiklou.git] / includes / jobqueue / jobs / PublishStashedFileJob.php
index 59166e8..78531dc 100644 (file)
@@ -35,8 +35,11 @@ class PublishStashedFileJob extends Job {
        }
 
        public function run() {
-               /** @noinspection PhpUnusedLocalVariableInspection */
                $scope = RequestContext::importScopedSession( $this->params['session'] );
+               $this->addTeardownCallback( function () use ( &$scope ) {
+                       ScopedCallback::consume( $scope ); // T126450
+               } );
+
                $context = RequestContext::getMain();
                $user = $context->getUser();
                try {
@@ -49,7 +52,7 @@ class PublishStashedFileJob extends Job {
                        UploadBase::setSessionStatus(
                                $user,
                                $this->params['filekey'],
-                               array( 'result' => 'Poll', 'stage' => 'publish', 'status' => Status::newGood() )
+                               [ 'result' => 'Poll', 'stage' => 'publish', 'status' => Status::newGood() ]
                        );
 
                        $upload = new UploadFromStash( $user );
@@ -63,11 +66,11 @@ class PublishStashedFileJob extends Job {
                        $verification = $upload->verifyUpload();
                        if ( $verification['status'] !== UploadBase::OK ) {
                                $status = Status::newFatal( 'verification-error' );
-                               $status->value = array( 'verification' => $verification );
+                               $status->value = [ 'verification' => $verification ];
                                UploadBase::setSessionStatus(
                                        $user,
                                        $this->params['filekey'],
-                                       array( 'result' => 'Failure', 'stage' => 'publish', 'status' => $status )
+                                       [ 'result' => 'Failure', 'stage' => 'publish', 'status' => $status ]
                                );
                                $this->setLastError( "Could not verify upload." );
 
@@ -79,15 +82,16 @@ class PublishStashedFileJob extends Job {
                                $this->params['comment'],
                                $this->params['text'],
                                $this->params['watch'],
-                               $user
+                               $user,
+                               isset( $this->params['tags'] ) ? $this->params['tags'] : []
                        );
                        if ( !$status->isGood() ) {
                                UploadBase::setSessionStatus(
                                        $user,
                                        $this->params['filekey'],
-                                       array( 'result' => 'Failure', 'stage' => 'publish', 'status' => $status )
+                                       [ 'result' => 'Failure', 'stage' => 'publish', 'status' => $status ]
                                );
-                               $this->setLastError( $status->getWikiText() );
+                               $this->setLastError( $status->getWikiText( false, false, 'en' ) );
 
                                return false;
                        }
@@ -103,23 +107,23 @@ class PublishStashedFileJob extends Job {
                        UploadBase::setSessionStatus(
                                $user,
                                $this->params['filekey'],
-                               array(
+                               [
                                        'result' => 'Success',
                                        'stage' => 'publish',
                                        'filename' => $upload->getLocalFile()->getName(),
                                        'imageinfo' => $imageInfo,
                                        'status' => Status::newGood()
-                               )
+                               ]
                        );
                } catch ( Exception $e ) {
                        UploadBase::setSessionStatus(
                                $user,
                                $this->params['filekey'],
-                               array(
+                               [
                                        'result' => 'Failure',
                                        'stage' => 'publish',
                                        'status' => Status::newFatal( 'api-error-publishfailed' )
-                               )
+                               ]
                        );
                        $this->setLastError( get_class( $e ) . ": " . $e->getMessage() );
                        // To prevent potential database referential integrity issues.
@@ -135,7 +139,7 @@ class PublishStashedFileJob extends Job {
        public function getDeduplicationInfo() {
                $info = parent::getDeduplicationInfo();
                if ( is_array( $info['params'] ) ) {
-                       $info['params'] = array( 'filekey' => $info['params']['filekey'] );
+                       $info['params'] = [ 'filekey' => $info['params']['filekey'] ];
                }
 
                return $info;