From c1f9b1f7b1b77776192048005dcc66dcf3df2bfb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 27 Dec 2014 15:41:37 +0100 Subject: Update to MediaWiki 1.24.1 --- includes/job/jobs/UploadFromUrlJob.php | 184 --------------------------------- 1 file changed, 184 deletions(-) delete mode 100644 includes/job/jobs/UploadFromUrlJob.php (limited to 'includes/job/jobs/UploadFromUrlJob.php') diff --git a/includes/job/jobs/UploadFromUrlJob.php b/includes/job/jobs/UploadFromUrlJob.php deleted file mode 100644 index c993cfb4..00000000 --- a/includes/job/jobs/UploadFromUrlJob.php +++ /dev/null @@ -1,184 +0,0 @@ -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(); - - 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; - - } - - /** - * Leave a message on the user talk page or in the session according to - * $params['leaveMessage']. - * - * @param $status Status - */ - protected function leaveMessage( $status ) { - if ( $this->params['leaveMessage'] ) { - if ( $status->isGood() ) { - $this->user->leaveUserMessage( wfMessage( 'upload-success-subj' )->text(), - wfMessage( 'upload-success-msg', - $this->upload->getTitle()->getText(), - $this->params['url'] - )->text() ); - } else { - $this->user->leaveUserMessage( wfMessage( 'upload-failure-subj' )->text(), - wfMessage( 'upload-failure-msg', - $status->getWikiText(), - $this->params['url'] - )->text() ); - } - } else { - wfSetupSession( $this->params['sessionId'] ); - if ( $status->isOk() ) { - $this->storeResultInSession( 'Success', - 'filename', $this->upload->getLocalFile()->getName() ); - } else { - $this->storeResultInSession( 'Failure', - 'errors', $status->getErrorsArray() ); - } - session_write_close(); - } - } - - /** - * Store a result in the session data. Note that the caller is responsible - * for appropriate session_start and session_write_close calls. - * - * @param string $result the result (Success|Warning|Failure) - * @param string $dataKey the key of the extra data - * @param $dataValue Mixed: the extra data itself - */ - protected function storeResultInSession( $result, $dataKey, $dataValue ) { - $session =& self::getSessionData( $this->params['sessionKey'] ); - $session['result'] = $result; - $session[$dataKey] = $dataValue; - } - - /** - * Initialize the session data. Sets the intial result to queued. - */ - public function initializeSessionData() { - $session =& self::getSessionData( $this->params['sessionKey'] ); - $$session['result'] = 'Queued'; - } - - /** - * @param $key - * @return mixed - */ - public static function &getSessionData( $key ) { - if ( !isset( $_SESSION[self::SESSION_KEYNAME][$key] ) ) { - $_SESSION[self::SESSION_KEYNAME][$key] = array(); - } - return $_SESSION[self::SESSION_KEYNAME][$key]; - } -} -- cgit v1.2.3-54-g00ecf