r81910 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81909‎ | r81910 | r81911 >
Date:18:24, 10 February 2011
Author:btongminh
Status:ok
Tags:
Comment:
Follow-up r70137: Unconditionalize the asyncdownload params and throw asynccopyuploadsdisabled if async is requested without $wgAllowAsyncCopyUploads.
Modified paths:
  • /trunk/phase3/includes/api/ApiUpload.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiUpload.php
@@ -147,14 +147,15 @@
148148 * @return bool
149149 */
150150 protected function selectUploadModule() {
151 - global $wgAllowAsyncCopyUploads;
152151 $request = $this->getMain()->getRequest();
153152
154153 // One and only one of the following parameters is needed
155154 $this->requireOnlyOneParameter( $this->mParams,
156155 'sessionkey', 'file', 'url', 'statuskey' );
157156
158 - if ( $wgAllowAsyncCopyUploads && $this->mParams['statuskey'] ) {
 157+ if ( $this->mParams['statuskey'] ) {
 158+ $this->checkAsyncDownloadEnabled();
 159+
159160 // Status request for an async upload
160161 $sessionData = UploadFromUrlJob::getSessionData( $this->mParams['statuskey'] );
161162 if ( !isset( $sessionData['result'] ) ) {
@@ -200,6 +201,8 @@
201202
202203 $async = false;
203204 if ( $this->mParams['asyncdownload'] ) {
 205+ $this->checkAsyncDownloadEnabled();
 206+
204207 if ( $this->mParams['leavemessage'] && !$this->mParams['ignorewarnings'] ) {
205208 $this->dieUsage( 'Using leavemessage without ignorewarnings is not supported',
206209 'missing-ignorewarnings' );
@@ -376,6 +379,16 @@
377380
378381 return $result;
379382 }
 383+
 384+ /**
 385+ * Checks if asynchronous copy uploads are enabled and throws an error if they are not.
 386+ */
 387+ protected function checkAsyncDownloadEnabled() {
 388+ global $wgAllowAsyncCopyUploads;
 389+ if ( !$wgAllowAsyncCopyUploads ) {
 390+ $this->dieUsage( 'Asynchronous copy uploads disabled', 'asynccopyuploaddisabled');
 391+ }
 392+ }
380393
381394 public function mustBePosted() {
382395 return true;
@@ -412,16 +425,12 @@
413426 'url' => null,
414427 'sessionkey' => null,
415428 'stash' => false,
 429+
 430+ 'asyncdownload' => false,
 431+ 'leavemessage' => false,
 432+ 'statuskey' => null,
416433 );
417434
418 - global $wgAllowAsyncCopyUploads;
419 - if ( $wgAllowAsyncCopyUploads ) {
420 - $params += array(
421 - 'asyncdownload' => false,
422 - 'leavemessage' => false,
423 - 'statuskey' => null,
424 - );
425 - }
426435 return $params;
427436 }
428437
@@ -437,18 +446,13 @@
438447 'file' => 'File contents',
439448 'url' => 'Url to fetch the file from',
440449 'sessionkey' => 'Session key that identifies a previous upload that was stashed temporarily.',
441 - 'stash' => 'If set, the server will not add the file to the repository and stash it temporarily.'
 450+ 'stash' => 'If set, the server will not add the file to the repository and stash it temporarily.',
 451+
 452+ 'asyncdownload' => 'Make fetching a URL asynchronous',
 453+ 'leavemessage' => 'If asyncdownload is used, leave a message on the user talk page if finished',
 454+ 'statuskey' => 'Fetch the upload status for this session key',
442455 );
443456
444 - global $wgAllowAsyncCopyUploads;
445 - if ( $wgAllowAsyncCopyUploads ) {
446 - $params += array(
447 - 'asyncdownload' => 'Make fetching a URL asynchronous',
448 - 'leavemessage' => 'If asyncdownload is used, leave a message on the user talk page if finished',
449 - 'statuskey' => 'Fetch the upload status for this session key',
450 - );
451 - }
452 -
453457 return $params;
454458
455459 }
@@ -483,6 +487,7 @@
484488 array( 'code' => 'internal-error', 'info' => 'An internal error occurred' ),
485489 array( 'code' => 'missingparam', 'info' => 'One of the parameters sessionkey, file, url, statuskey is required' ),
486490 array( 'code' => 'invalidparammix', 'info' => 'The parameters sessionkey, file, url, statuskey can not be used together' ),
 491+ array( 'code' => 'asynccopyuploaddisabled', 'info' => 'Asynchronous copy uploads disabled' ),
487492 ) );
488493 }
489494

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r70137Made asynchronous upload by URL working, partly. Hid it behind $wgAllowAsyncC...btongminh13:53, 29 July 2010

Status & tagging log