Example #1
0
 public function run()
 {
     global $wgCopyUploadAsyncTimeout;
     # Initialize this object and the upload object
     $this->upload = new UploadFromUrl();
     $this->upload->initialize($this->title->getText(), $this->params['url'], false);
     $this->user = User::newFromName($this->params['userName']);
     # Fetch the file
     $opts = array();
     if ($wgCopyUploadAsyncTimeout) {
         $opts['timeout'] = $wgCopyUploadAsyncTimeout;
     }
     $status = $this->upload->fetchFile($opts);
     if (!$status->isOk()) {
         $this->leaveMessage($status);
         return true;
     }
     # Verify upload
     $result = $this->upload->verifyUpload();
     if ($result['status'] != UploadBase::OK) {
         $status = $this->upload->convertVerifyErrorToStatus($result);
         $this->leaveMessage($status);
         return true;
     }
     # Check warnings
     if (!$this->params['ignoreWarnings']) {
         $warnings = $this->upload->checkWarnings();
         if ($warnings) {
             # Stash the upload
             $key = $this->upload->stashFile();
             // @todo FIXME: This has been broken for a while.
             // User::leaveUserMessage() does not exist.
             if ($this->params['leaveMessage']) {
                 $this->user->leaveUserMessage(wfMessage('upload-warning-subj')->text(), wfMessage('upload-warning-msg', $key, $this->params['url'])->text());
             } else {
                 wfSetupSession($this->params['sessionId']);
                 $this->storeResultInSession('Warning', 'warnings', $warnings);
                 session_write_close();
             }
             return true;
         }
     }
     # Perform the upload
     $status = $this->upload->performUpload($this->params['comment'], $this->params['pageText'], $this->params['watch'], $this->user);
     $this->leaveMessage($status);
     return true;
 }
 public function run()
 {
     # Initialize this object and the upload object
     $this->upload = new UploadFromUrl();
     $this->upload->initialize($this->title->getText(), $this->params['url'], false);
     $this->user = User::newFromName($this->params['userName']);
     # Fetch the file
     $status = $this->upload->fetchFile();
     if (!$status->isOk()) {
         $this->leaveMessage($status);
         return true;
     }
     # Verify upload
     $result = $this->upload->verifyUpload();
     if ($result['status'] != UploadBase::OK) {
         $status = $this->upload->convertVerifyErrorToStatus($result);
         $this->leaveMessage($status);
         return true;
     }
     # Check warnings
     if (!$this->params['ignoreWarnings']) {
         $warnings = $this->upload->checkWarnings();
         if ($warnings) {
             # Stash the upload
             $key = $this->upload->stashFile();
             if ($this->params['leaveMessage']) {
                 $this->user->leaveUserMessage(wfMsg('upload-warning-subj'), wfMsg('upload-warning-msg', $key, $this->params['url']));
             } else {
                 wfSetupSession($this->params['sessionId']);
                 $this->storeResultInSession('Warning', 'warnings', $warnings);
                 session_write_close();
             }
             return true;
         }
     }
     # Perform the upload
     $status = $this->upload->performUpload($this->params['comment'], $this->params['pageText'], $this->params['watch'], $this->user);
     $this->leaveMessage($status);
     return true;
 }