X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fjob%2Fjobs%2FPublishStashedFileJob.php;h=5a24f93c3c1caebb2d393eb31201dcf6b675de7e;hb=0b580213bfaaa2cc9d48cc55777843cb24beaf55;hp=594d30493bb9f707c5624800c65e1b43b8305c40;hpb=e439cfb1b1dd71417162e23174554e1148707bd6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/job/jobs/PublishStashedFileJob.php b/includes/job/jobs/PublishStashedFileJob.php index 594d30493b..5a24f93c3c 100644 --- a/includes/job/jobs/PublishStashedFileJob.php +++ b/includes/job/jobs/PublishStashedFileJob.php @@ -37,18 +37,28 @@ class PublishStashedFileJob extends Job { $context = RequestContext::getMain(); try { $user = $context->getUser(); - if ( !$user->isLoggedIn() || $user->getId() != $this->params['userid'] ) { + if ( !$user->isLoggedIn() ) { $this->setLastError( "Could not load the author user from session." ); - return true; // no retries + return false; } + if ( count( $_SESSION ) === 0 ) { + // Empty session probably indicates that we didn't associate + // with the session correctly. Note that being able to load + // the user does not necessarily mean the session was loaded. + // Most likely cause by suhosin.session.encrypt = On. + $this->setLastError( "Error associating with user session. Try setting suhosin.session.encrypt = Off" ); + return false; + } + + UploadBase::setSessionStatus( $this->params['filekey'], array( 'result' => 'Poll', 'stage' => 'publish', 'status' => Status::newGood() ) ); $upload = new UploadFromStash( $user ); - // @TODO: initialize() causes a GET, ideally we could frontload the antivirus + // @todo initialize() causes a GET, ideally we could frontload the antivirus // checks and anything else to the stash stage (which includes concatenation and // the local file is thus already there). That way, instead of GET+PUT, there could // just be a COPY operation from the stash to the public zone. @@ -64,7 +74,7 @@ class PublishStashedFileJob extends Job { array( 'result' => 'Failure', 'stage' => 'publish', 'status' => $status ) ); $this->setLastError( "Could not verify upload." ); - return true; // no retries + return false; } // Upload the stashed file to a permanent location @@ -80,7 +90,7 @@ class PublishStashedFileJob extends Job { array( 'result' => 'Failure', 'stage' => 'publish', 'status' => $status ) ); $this->setLastError( $status->getWikiText() ); - return true; // no retries + return false; } // Build the image info array while we have the local reference handy @@ -94,11 +104,11 @@ class PublishStashedFileJob extends Job { UploadBase::setSessionStatus( $this->params['filekey'], array( - 'result' => 'Success', - 'stage' => 'publish', - 'filename' => $upload->getLocalFile()->getName(), + 'result' => 'Success', + 'stage' => 'publish', + 'filename' => $upload->getLocalFile()->getName(), 'imageinfo' => $imageInfo, - 'status' => Status::newGood() + 'status' => Status::newGood() ) ); } catch ( MWException $e ) { @@ -106,18 +116,16 @@ class PublishStashedFileJob extends Job { $this->params['filekey'], array( 'result' => 'Failure', - 'stage' => 'publish', + 'stage' => 'publish', 'status' => Status::newFatal( 'api-error-publishfailed' ) ) ); $this->setLastError( get_class( $e ) . ": " . $e->getText() ); + return false; } - return true; // returns true on success and erro (no retries) + return true; } - /** - * @return Array - */ public function getDeduplicationInfo() { $info = parent::getDeduplicationInfo(); if ( is_array( $info['params'] ) ) { @@ -125,4 +133,8 @@ class PublishStashedFileJob extends Job { } return $info; } + + public function allowRetries() { + return false; + } }