-
- /**
- * Wrapper around the parent function in order to defer verifying the
- * upload until the file really has been fetched.
- * @return array|mixed
- */
- public function verifyUpload() {
- if ( $this->mAsync ) {
- return array( 'status' => UploadBase::OK );
- }
-
- return parent::verifyUpload();
- }
-
- /**
- * Wrapper around the parent function in order to defer checking warnings
- * until the file really has been fetched.
- * @return array
- */
- public function checkWarnings() {
- if ( $this->mAsync ) {
- $this->mIgnoreWarnings = false;
-
- return array();
- }
-
- return parent::checkWarnings();
- }
-
- /**
- * Wrapper around the parent function in order to defer checking protection
- * until we are sure that the file can actually be uploaded
- * @param User $user
- * @return bool|mixed
- */
- public function verifyTitlePermissions( $user ) {
- if ( $this->mAsync ) {
- return true;
- }
-
- return parent::verifyTitlePermissions( $user );
- }
-
- /**
- * Wrapper around the parent function in order to defer uploading to the
- * job queue for asynchronous uploads
- * @param string $comment
- * @param string $pageText
- * @param bool $watch
- * @param User $user
- * @return Status
- */
- public function performUpload( $comment, $pageText, $watch, $user ) {
- if ( $this->mAsync ) {
- $sessionKey = $this->insertJob( $comment, $pageText, $watch, $user );
-
- return Status::newFatal( 'async', $sessionKey );
- }
-
- return parent::performUpload( $comment, $pageText, $watch, $user );
- }
-
- /**
- * @param string $comment
- * @param string $pageText
- * @param bool $watch
- * @param User $user
- * @return string
- */
- protected function insertJob( $comment, $pageText, $watch, $user ) {
- $sessionKey = $this->stashSession();
- $job = new UploadFromUrlJob( $this->getTitle(), array(
- 'url' => $this->mUrl,
- 'comment' => $comment,
- 'pageText' => $pageText,
- 'watch' => $watch,
- 'userName' => $user->getName(),
- 'leaveMessage' => $this->mAsync == 'async-leavemessage',
- 'ignoreWarnings' => $this->mIgnoreWarnings,
- 'sessionId' => MediaWiki\Session\SessionManager::getGlobalSession()->getId(),
- 'sessionKey' => $sessionKey,
- ) );
- $job->initializeSessionData();
- JobQueueGroup::singleton()->push( $job );
-
- return $sessionKey;
- }