From: Michael Dale Date: Wed, 28 Oct 2009 03:38:23 +0000 (+0000) Subject: ( bug 21320 ) adds early checks for wgAllowCopyUpload and 'upload_by_url' permission... X-Git-Tag: 1.31.0-rc.0~39068 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dcompta/operations/modifier.php?a=commitdiff_plain;h=7e0fcad32b9e5c83f8be1e84a81c24b7eae37a77;p=lhc%2Fweb%2Fwiklou.git ( bug 21320 ) adds early checks for wgAllowCopyUpload and 'upload_by_url' permission so that web server does not make extra requests. --- diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index c421e47c00..97da929108 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -38,7 +38,7 @@ class ApiUpload extends ApiBase { } public function execute() { - global $wgUser; + global $wgUser, $wgAllowCopyUploads; $this->getMain()->isWriteMode(); $this->mParams = $this->extractRequestParams(); @@ -133,6 +133,15 @@ class ApiUpload extends ApiBase { $request->getFileSize( 'file' ) ); } elseif ( isset( $this->mParams['url'] ) ) { + //make sure upload by url is enabled: + if( !$wgAllowCopyUploads ) + $this->dieUsageMsg( array( 'uploaddisabled' ) ); + + //make sure the current user can upload + if(! $wgUser->isAllowed('upload_by_url') ) + $this->dieUsageMsg( array( 'badaccess-groups' ) ); + + $this->mUpload = new UploadFromUrl(); $this->mUpload->initialize( $this->mParams['filename'], $this->mParams['url'], $this->mParams['asyncdownload'] );