Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / includes / jobqueue / jobs / PublishStashedFileJob.php
index 8a180ec..a6d2f70 100644 (file)
@@ -35,7 +35,12 @@ 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 {
@@ -48,7 +53,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 );
@@ -62,11 +67,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." );
 
@@ -78,13 +83,14 @@ 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() );
 
@@ -102,25 +108,25 @@ 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->getText() );
+                       $this->setLastError( get_class( $e ) . ": " . $e->getMessage() );
                        // To prevent potential database referential integrity issues.
                        // See bug 32551.
                        MWExceptionHandler::rollbackMasterChangesAndLog( $e );
@@ -134,7 +140,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;