jenkins-bot has submitted this change and it was merged.
Change subject: API: Improve upload error reporting
......................................................................
API: Improve upload error reporting
* Include the detailed message text in the error for verification-error and
hookaborted
* Actually return the raw "details" for hookaborted and unknown-error
(previously it was colliding with the standard "error" and "code"
elements).
Bug: T105224
Change-Id: I13b7b6ad02fbbf46bf3d6b4c683493b2fecf8c58
---
M includes/api/ApiUpload.php
1 file changed, 15 insertions(+), 4 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php
index 54294c9..398337b 100644
--- a/includes/api/ApiUpload.php
+++ b/includes/api/ApiUpload.php
@@ -527,17 +527,28 @@
$this->dieUsage( $msg, 'filetype-banned', 0,
$extradata );
break;
case UploadBase::VERIFICATION_ERROR:
+ $params = $verification['details'];
+ $key = array_shift( $params );
+ $msg = $this->msg( $key, $params )->inLanguage(
'en' )->useDatabase( false )->text();
ApiResult::setIndexedTagName(
$verification['details'], 'detail' );
- $this->dieUsage( 'This file did not pass file
verification', 'verification-error',
+ $this->dieUsage( "This file did not pass file
verification: $msg", 'verification-error',
0, array( 'details' =>
$verification['details'] ) );
break;
case UploadBase::HOOK_ABORTED:
- $this->dieUsage( "The modification you tried to
make was aborted by an extension hook",
- 'hookaborted', 0, array( 'error' =>
$verification['error'] ) );
+ if ( is_array( $verification['error'] ) ) {
+ $params = $verification['error'];
+ } elseif ( $verification['error'] !== '' ) {
+ $params = array( $verification['error']
);
+ } else {
+ $params = array( 'hookaborted' );
+ }
+ $key = array_shift( $params );
+ $msg = $this->msg( $key, $params )->inLanguage(
'en' )->useDatabase( false )->text();
+ $this->dieUsage( $msg, 'hookaborted', 0, array(
'details' => $verification['error'] ) );
break;
default:
$this->dieUsage( 'An unknown error occurred',
'unknown-error',
- 0, array( 'code' =>
$verification['status'] ) );
+ 0, array( 'details' => array( 'code' =>
$verification['status'] ) ) );
break;
}
}
--
To view, visit https://gerrit.wikimedia.org/r/224067
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I13b7b6ad02fbbf46bf3d6b4c683493b2fecf8c58
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
Gerrit-Reviewer: Gergő Tisza <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Magnus Manske <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits