Merge "Missing space between variable name and docstring"
[lhc/web/wiklou.git] / includes / api / ApiUpload.php
index a283b5a..f0d271c 100644 (file)
@@ -1,9 +1,5 @@
 <?php
 /**
- *
- *
- * Created on Aug 21, 2008
- *
  * Copyright © 2008 - 2010 Bryan Tong Minh <Bryan.TongMinh@Gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -71,27 +67,15 @@ class ApiUpload extends ApiBase {
                $this->checkPermissions( $user );
 
                // Fetch the file (usually a no-op)
-               /** @var $status Status */
+               /** @var Status $status */
                $status = $this->mUpload->fetchFile();
                if ( !$status->isGood() ) {
                        $this->dieStatus( $status );
                }
 
                // Check if the uploaded file is sane
-               if ( $this->mParams['chunk'] ) {
-                       $maxSize = UploadBase::getMaxUploadSize();
-                       if ( $this->mParams['filesize'] > $maxSize ) {
-                               $this->dieWithError( 'file-too-large' );
-                       }
-                       if ( !$this->mUpload->getTitle() ) {
-                               $this->dieWithError( 'illegal-filename' );
-                       }
-               } elseif ( $this->mParams['async'] && $this->mParams['filekey'] ) {
-                       // defer verification to background process
-               } else {
-                       wfDebug( __METHOD__ . " about to verify\n" );
-                       $this->verifyUpload();
-               }
+               wfDebug( __METHOD__ . " about to verify\n" );
+               $this->verifyUpload();
 
                // Check if the user has the rights to modify or overwrite the requested title
                // (This check is irrelevant if stashing is already requested, since the errors
@@ -421,7 +405,7 @@ class ApiUpload extends ApiBase {
                if ( $this->mParams['filekey'] && $this->mParams['checkstatus'] ) {
                        $progress = UploadBase::getSessionStatus( $this->getUser(), $this->mParams['filekey'] );
                        if ( !$progress ) {
-                               $this->dieWithError( 'api-upload-missingresult', 'missingresult' );
+                               $this->dieWithError( 'apierror-upload-missingresult', 'missingresult' );
                        } elseif ( !$progress['status']->isGood() ) {
                                $this->dieStatusWithCode( $progress['status'], 'stashfailed' );
                        }
@@ -546,7 +530,7 @@ class ApiUpload extends ApiBase {
                }
 
                // Check blocks
-               if ( $user->isBlocked() ) {
+               if ( $user->isBlockedFromUpload() ) {
                        $this->dieBlocked( $user->getBlock() );
                }
 
@@ -686,9 +670,7 @@ class ApiUpload extends ApiBase {
                                $warning = $warnings['exists'];
                                unset( $warnings['exists'] );
                                /** @var LocalFile $localFile */
-                               $localFile = isset( $warning['normalizedFile'] )
-                                       ? $warning['normalizedFile']
-                                       : $warning['file'];
+                               $localFile = $warning['normalizedFile'] ?? $warning['file'];
                                $warnings[$warning['warning']] = $localFile->getName();
                        }
 
@@ -728,26 +710,26 @@ class ApiUpload extends ApiBase {
         */
        protected function handleStashException( $e ) {
                switch ( get_class( $e ) ) {
-                       case 'UploadStashFileNotFoundException':
+                       case UploadStashFileNotFoundException::class:
                                $wrap = 'apierror-stashedfilenotfound';
                                break;
-                       case 'UploadStashBadPathException':
+                       case UploadStashBadPathException::class:
                                $wrap = 'apierror-stashpathinvalid';
                                break;
-                       case 'UploadStashFileException':
+                       case UploadStashFileException::class:
                                $wrap = 'apierror-stashfilestorage';
                                break;
-                       case 'UploadStashZeroLengthFileException':
+                       case UploadStashZeroLengthFileException::class:
                                $wrap = 'apierror-stashzerolength';
                                break;
-                       case 'UploadStashNotLoggedInException':
+                       case UploadStashNotLoggedInException::class:
                                return StatusValue::newFatal( ApiMessage::create(
                                        [ 'apierror-mustbeloggedin', $this->msg( 'action-upload' ) ], 'stashnotloggedin'
                                ) );
-                       case 'UploadStashWrongOwnerException':
+                       case UploadStashWrongOwnerException::class:
                                $wrap = 'apierror-stashwrongowner';
                                break;
-                       case 'UploadStashNoSuchKeyException':
+                       case UploadStashNoSuchKeyException::class:
                                $wrap = 'apierror-stashnosuchfilekey';
                                break;
                        default:
@@ -772,7 +754,7 @@ class ApiUpload extends ApiBase {
                        $this->mParams['text'] = $this->mParams['comment'];
                }
 
-               /** @var $file LocalFile */
+               /** @var LocalFile $file */
                $file = $this->mUpload->getLocalFile();
 
                // For preferences mode, we want to watch if 'watchdefault' is set,
@@ -829,7 +811,7 @@ class ApiUpload extends ApiBase {
                        $result['result'] = 'Poll';
                        $result['stage'] = 'queued';
                } else {
-                       /** @var $status Status */
+                       /** @var Status $status */
                        $status = $this->mUpload->performUpload( $this->mParams['comment'],
                                $this->mParams['text'], $watch, $this->getUser(), $this->mParams['tags'] );