X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiUpload.php;h=373ec112716f4f28932e73f36ee5c07b9be4841f;hb=5455d4c43122d66e1bc1a62d700684e14f13e557;hp=f0d271cb04c07a0e768f961f79449c63cbeef064;hpb=18a53cb48bc5848e490f3bc1c444e26ef8bc8299;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index f0d271cb04..373ec11271 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -74,8 +74,20 @@ class ApiUpload extends ApiBase { } // Check if the uploaded file is sane - wfDebug( __METHOD__ . " about to verify\n" ); - $this->verifyUpload(); + 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(); + } // 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 @@ -646,7 +658,7 @@ class ApiUpload extends ApiBase { * @return array */ protected function getApiWarnings() { - $warnings = $this->mUpload->checkWarnings(); + $warnings = UploadBase::makeWarningsSerializable( $this->mUpload->checkWarnings() ); return $this->transformWarnings( $warnings ); } @@ -658,9 +670,8 @@ class ApiUpload extends ApiBase { if ( isset( $warnings['duplicate'] ) ) { $dupes = []; - /** @var File $dupe */ foreach ( $warnings['duplicate'] as $dupe ) { - $dupes[] = $dupe->getName(); + $dupes[] = $dupe['fileName']; } ApiResult::setIndexedTagName( $dupes, 'duplicate' ); $warnings['duplicate'] = $dupes; @@ -669,27 +680,24 @@ class ApiUpload extends ApiBase { if ( isset( $warnings['exists'] ) ) { $warning = $warnings['exists']; unset( $warnings['exists'] ); - /** @var LocalFile $localFile */ $localFile = $warning['normalizedFile'] ?? $warning['file']; - $warnings[$warning['warning']] = $localFile->getName(); + $warnings[$warning['warning']] = $localFile['fileName']; } if ( isset( $warnings['no-change'] ) ) { - /** @var File $file */ $file = $warnings['no-change']; unset( $warnings['no-change'] ); $warnings['nochange'] = [ - 'timestamp' => wfTimestamp( TS_ISO_8601, $file->getTimestamp() ) + 'timestamp' => wfTimestamp( TS_ISO_8601, $file['timestamp'] ) ]; } if ( isset( $warnings['duplicate-version'] ) ) { $dupes = []; - /** @var File $dupe */ foreach ( $warnings['duplicate-version'] as $dupe ) { $dupes[] = [ - 'timestamp' => wfTimestamp( TS_ISO_8601, $dupe->getTimestamp() ) + 'timestamp' => wfTimestamp( TS_ISO_8601, $dupe['timestamp'] ) ]; } unset( $warnings['duplicate-version'] ); @@ -786,6 +794,7 @@ class ApiUpload extends ApiBase { } // No errors, no warnings: do the upload + $result = []; if ( $this->mParams['async'] ) { $progress = UploadBase::getSessionStatus( $this->getUser(), $this->mParams['filekey'] ); if ( $progress && $progress['result'] === 'Poll' ) {