summaryrefslogtreecommitdiff
path: root/includes/upload/UploadFromUrl.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2012-05-03 13:01:35 +0200
committerPierre Schmitz <pierre@archlinux.de>2012-05-03 13:01:35 +0200
commitd9022f63880ce039446fba8364f68e656b7bf4cb (patch)
tree16b40fbf17bf7c9ee6f4ead25b16dd192378050a /includes/upload/UploadFromUrl.php
parent27cf83d177256813e2e802241085fce5dd0f3fb9 (diff)
Update to MediaWiki 1.19.0
Diffstat (limited to 'includes/upload/UploadFromUrl.php')
-rw-r--r--includes/upload/UploadFromUrl.php26
1 files changed, 17 insertions, 9 deletions
diff --git a/includes/upload/UploadFromUrl.php b/includes/upload/UploadFromUrl.php
index 8178988f..da772fe2 100644
--- a/includes/upload/UploadFromUrl.php
+++ b/includes/upload/UploadFromUrl.php
@@ -2,27 +2,28 @@
/**
* Implements uploading from a HTTP resource.
*
- * @file
- * @ingroup upload
+ * @ingroup Upload
* @author Bryan Tong Minh
* @author Michael Dale
*/
-
class UploadFromUrl extends UploadBase {
protected $mAsync, $mUrl;
protected $mIgnoreWarnings = true;
- protected $mTempPath;
+ protected $mTempPath, $mTmpHandle;
/**
* Checks if the user is allowed to use the upload-by-URL feature. If the
* user is allowed, pass on permissions checking to the parent.
*
* @param $user User
+ *
+ * @return bool
*/
public static function isAllowed( $user ) {
- if ( !$user->isAllowed( 'upload_by_url' ) )
+ if ( !$user->isAllowed( 'upload_by_url' ) ) {
return 'upload_by_url';
+ }
return parent::isAllowed( $user );
}
@@ -64,8 +65,9 @@ class UploadFromUrl extends UploadBase {
*/
public function initializeFromRequest( &$request ) {
$desiredDestName = $request->getText( 'wpDestFile' );
- if ( !$desiredDestName )
+ if ( !$desiredDestName ) {
$desiredDestName = $request->getText( 'wpUploadFileURL' );
+ }
return $this->initialize(
$desiredDestName,
trim( $request->getVal( 'wpUploadFileURL' ) ),
@@ -75,6 +77,7 @@ class UploadFromUrl extends UploadBase {
/**
* @param $request WebRequest object
+ * @return bool
*/
public static function isValidRequest( $request ) {
global $wgUser;
@@ -85,8 +88,14 @@ class UploadFromUrl extends UploadBase {
&& $wgUser->isAllowed( 'upload_by_url' );
}
+ /**
+ * @return string
+ */
public function getSourceType() { return 'url'; }
+ /**
+ * @return Status
+ */
public function fetchFile() {
if ( !Http::isValidURI( $this->mUrl ) ) {
return Status::newFatal( 'http-invalid-url' );
@@ -130,6 +139,7 @@ class UploadFromUrl extends UploadBase {
/**
* 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 ) {
@@ -209,9 +219,7 @@ class UploadFromUrl extends UploadBase {
if ( $this->mAsync ) {
$sessionKey = $this->insertJob( $comment, $pageText, $watch, $user );
- $status = new Status;
- $status->error( 'async', $sessionKey );
- return $status;
+ return Status::newFatal( 'async', $sessionKey );
}
return parent::performUpload( $comment, $pageText, $watch, $user );