X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiUpload.php;h=2c5b583f3be9463295634c2bd5163e17d8227b3c;hb=d28eb17a50f95c169b46ae92f99d18c95ae30105;hp=cfe19689382506433cb419808bf23efdb91b714f;hpb=237d3271fd313ebe09858a5c442a91216a7b61cf;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index cfe1968938..f0d271cb04 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -1,9 +1,5 @@ * * This program is free software; you can redistribute it and/or modify @@ -78,20 +74,8 @@ class ApiUpload extends ApiBase { } // 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: