* user is not allowed, return the name of the user right as a string. If
* the user is allowed, have the parent do further permissions checking.
*
- * @param $user User
+ * @param User $user
*
* @return bool|string
*/
if ( !$user->isAllowed( 'upload_by_url' ) ) {
return 'upload_by_url';
}
+
return parent::isAllowed( $user );
}
*/
public static function isEnabled() {
global $wgAllowCopyUploads;
+
return $wgAllowCopyUploads && parent::isEnabled();
}
* The domains in the whitelist can include wildcard characters (*) in place
* of any of the domain levels, e.g. '*.flickr.com' or 'upload.*.gov.uk'.
*
- * @param $url string
+ * @param string $url
* @return bool
*/
public static function isAllowedHost( $url ) {
}
*/
}
+
return $valid;
}
/**
* Checks whether the URL is not allowed.
*
- * @param $url string
+ * @param string $url
* @return bool
*/
public static function isAllowedUrl( $url ) {
wfRunHooks( 'IsUploadAllowedFromUrl', array( $url, &$allowed ) );
self::$allowedUrls[$url] = $allowed;
}
+
return self::$allowedUrls[$url];
}
/**
* Entry point for API upload
*
- * @param $name string
- * @param $url string
- * @param $async mixed Whether the download should be performed
+ * @param string $name
+ * @param string $url
+ * @param bool|string $async Whether the download should be performed
* asynchronous. False for synchronous, async or async-leavemessage for
* asynchronous download.
* @throws MWException
/**
* Entry point for SpecialUpload
- * @param $request WebRequest object
+ * @param WebRequest $request
*/
public function initializeFromRequest( &$request ) {
$desiredDestName = $request->getText( 'wpDestFile' );
}
/**
- * @param $request WebRequest object
+ * @param WebRequest $request
* @return bool
*/
public static function isValidRequest( $request ) {
global $wgUser;
$url = $request->getVal( 'wpUploadFileURL' );
+
return !empty( $url )
&& Http::isValidURI( $url )
&& $wgUser->isAllowed( 'upload_by_url' );
/**
* Download the file (if not async)
*
- * @param Array $httpOptions Array of options for MWHttpRequest. Ignored if async.
+ * @param array $httpOptions Array of options for MWHttpRequest. Ignored if async.
* This could be used to override the timeout on the http request.
* @return Status
*/
if ( !$this->mAsync ) {
return $this->reallyFetchFile( $httpOptions );
}
+
return Status::newGood();
}
protected function makeTemporaryFile() {
$tmpFile = TempFSFile::factory( 'URL' );
$tmpFile->bind( $this );
+
return $tmpFile->getPath();
}
/**
* Callback: save a chunk of the result of a HTTP request to the temporary file
*
- * @param $req mixed
- * @param $buffer string
- * @return int number of bytes handled
+ * @param mixed $req
+ * @param string $buffer
+ * @return int Number of bytes handled
*/
public function saveTempFileChunk( $req, $buffer ) {
$nbytes = fwrite( $this->mTmpHandle, $buffer );
* Download the file, save it to the temporary file and update the file
* size and set $mRemoveTempFile to true.
*
- * @param Array $httpOptions Array of options for MWHttpRequest
+ * @param array $httpOptions Array of options for MWHttpRequest
* @return Status
*/
protected function reallyFetchFile( $httpOptions = array() ) {
$this->mRemoveTempFile = true;
$this->mFileSize = 0;
- $options = $httpOptions + array(
- 'followRedirects' => true,
- );
+ $options = $httpOptions + array( 'followRedirects' => true );
+
if ( $wgCopyUploadProxy !== false ) {
$options['proxy'] = $wgCopyUploadProxy;
}
+
if ( $wgCopyUploadTimeout && !isset( $options['timeout'] ) ) {
$options['timeout'] = $wgCopyUploadTimeout;
}
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
+ * @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
+ * @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 $comment string
- * @param $pageText string
- * @param $watch bool
- * @param $user User
+ * @param string $comment
+ * @param string $pageText
+ * @param bool $watch
+ * @param User $user
* @return Status
*/
public function performUpload( $comment, $pageText, $watch, $user ) {
}
/**
- * @param $comment
- * @param $pageText
- * @param $watch
- * @param $user User
- * @return String
+ * @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->initializeSessionData();
JobQueueGroup::singleton()->push( $job );
+
return $sessionKey;
}
-
}