- $status = $this->mUpload->performUpload( $this->mParams['comment'],
- $this->mParams['text'], $watch, $this->getUser() );
-
- if ( !$status->isGood() ) {
- $error = $status->getErrorsArray();
-
- if ( count( $error ) == 1 && $error[0][0] == 'async' ) {
- // The upload can not be performed right now, because the user
- // requested so
- return array(
- 'result' => 'Queued',
- 'statuskey' => $error[0][1],
- );
+ if ( $this->mParams['async'] ) {
+ $progress = UploadBase::getSessionStatus( $this->mParams['filekey'] );
+ if ( $progress && $progress['result'] === 'Poll' ) {
+ $this->dieUsage( "Upload from stash already in progress.", 'publishfailed' );
+ }
+ UploadBase::setSessionStatus(
+ $this->mParams['filekey'],
+ array( 'result' => 'Poll', 'stage' => 'queued', 'status' => Status::newGood() )
+ );
+ $retVal = 1;
+ $cmd = wfShellWikiCmd(
+ "$IP/includes/upload/PublishStashedFile.php",
+ array(
+ '--wiki', wfWikiID(),
+ '--filename', $this->mParams['filename'],
+ '--filekey', $this->mParams['filekey'],
+ '--userid', $this->getUser()->getId(),
+ '--comment', $this->mParams['comment'],
+ '--text', $this->mParams['text'],
+ '--watch', $watch,
+ '--sessionid', session_id(),
+ '--quiet'
+ )
+ ) . " < " . wfGetNull() . " > " . wfGetNull() . " 2>&1 &";
+ // Start a process in the background. Enforce the time limits via PHP
+ // since ulimit4.sh seems to often not work for this particular usage.
+ wfShellExec( $cmd, $retVal, array(), array( 'time' => 0, 'memory' => 0 ) );
+ if ( $retVal == 0 ) {
+ $result['result'] = 'Poll';