* @ingroup JobQueue
*/
class PublishStashedFileJob extends Job {
- public function __construct( $title, $params ) {
+ public function __construct( Title $title, array $params ) {
parent::__construct( 'PublishStashedFile', $title, $params );
$this->removeDuplicates = true;
}
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 {
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 );
$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." );
$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() );
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 );
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;