Example #1
0
 /**
  * Download the file, save it to the temporary file and update the file
  * size and set $mRemoveTempFile to true.
  * @return Status
  */
 protected function reallyFetchFile()
 {
     if ($this->mTempPath === false) {
         return Status::newFatal('tmp-create-error');
     }
     // Note the temporary file should already be created by makeTemporaryFile()
     $this->mTmpHandle = fopen($this->mTempPath, 'wb');
     if (!$this->mTmpHandle) {
         return Status::newFatal('tmp-create-error');
     }
     $this->mRemoveTempFile = true;
     $this->mFileSize = 0;
     /* Wikia change - begin */
     $options = array('followRedirects' => true);
     wfRunHooks('UploadFromUrlReallyFetchFile', array(&$options));
     if (UploadFromUrl::isValidBase64($this->mUrl)) {
         $status = $this->saveTempBase64();
     } else {
         $req = MWHttpRequest::factory($this->mUrl, $options);
         $req->setCallback(array($this, 'saveTempFileChunk'));
         $status = $req->execute();
     }
     /* Wikia change - end */
     if ($this->mTmpHandle) {
         // File got written ok...
         fclose($this->mTmpHandle);
         $this->mTmpHandle = null;
     } else {
         // We encountered a write error during the download...
         return Status::newFatal('tmp-write-error');
     }
     if (!$status->isOk()) {
         return $status;
     }
     return $status;
 }