Bartosz Dziewoński has submitted this change and it was merged.
Change subject: UploadFromRequest: Actually detect failed uploads
......................................................................
UploadFromRequest: Actually detect failed uploads
Pretty sure mTmpHandle is always set and never falsy. Instead, check
mFileSize being zero, which indicates that no chunks were received.
Change-Id: Ibe6348a3949ca065e5a16cb4b68d2d6fa9c252b7
---
M ApiImageTweaks.php
M includes/UploadFromRequest.php
2 files changed, 8 insertions(+), 6 deletions(-)
Approvals:
MarkTraceur: Looks good to me, approved
Bartosz Dziewoński: Verified
diff --git a/ApiImageTweaks.php b/ApiImageTweaks.php
index cf6576c..7fc9727 100644
--- a/ApiImageTweaks.php
+++ b/ApiImageTweaks.php
@@ -39,7 +39,11 @@
$params = $this->extractRequestParams();
$upload = new UploadFromLocalFile;
$upload->initializeFromParams( $params, $thumborURL );
- $upload->fetchFile();
+
+ $status = $upload->fetchFile();
+ if ( !$status->isOK() ) {
+ $this->dieStatus( $status );
+ }
$result = array();
diff --git a/includes/UploadFromRequest.php b/includes/UploadFromRequest.php
index 74df083..751bff4 100644
--- a/includes/UploadFromRequest.php
+++ b/includes/UploadFromRequest.php
@@ -124,11 +124,9 @@
$this->mRequest->setCallback( array( $this, 'saveTempFileChunk'
) );
$status = $this->mRequest->execute();
- if ( $this->mTmpHandle ) {
- // File got written ok...
- fclose( $this->mTmpHandle );
- $this->mTmpHandle = null;
- } else {
+ fclose( $this->mTmpHandle );
+ $this->mTmpHandle = null;
+ if ( !$this->mFileSize ) {
// We encountered a write error during the download...
return Status::newFatal( 'tmp-write-error' );
}
--
To view, visit https://gerrit.wikimedia.org/r/281970
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibe6348a3949ca065e5a16cb4b68d2d6fa9c252b7
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/ImageTweaks
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits