From ee0cbd5dcac80ba02f037ad6ff1970892ffd7ee8 Mon Sep 17 00:00:00 2001 From: Daniel Kinzler Date: Fri, 13 Nov 2009 16:08:17 +0000 Subject: [PATCH] allow UploadVerification hooks to return error details --- docs/hooks.txt | 5 ++++- includes/specials/SpecialUpload.php | 11 +++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 45757b0ff4..eeb7eac7e9 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1549,7 +1549,10 @@ array $descriptor: the HTMLForm descriptor 'UploadVerification': additional chances to reject an uploaded file string $saveName: destination file name string $tempName: filesystem path to the temporary file for checks -string &$error: output: HTML error to show if upload canceled by returning false +string &$error: output: message key for message to show if upload canceled + by returning false. May also be an array, where the first element + is the message key and the remaining elements are used as parameters to + the message. 'UploadComplete': Upon completion of a file upload $uploadBase: UploadBase (or subclass) object. File can be accessed by diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index 7f877ae99c..965c3bf1c5 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -474,8 +474,15 @@ class SpecialUpload extends SpecialPage { $this->uploadError( wfMsgExt( $code, 'parseinline', $details['details'] ) ); break; case UploadBase::HOOK_ABORTED: - $error = $details['error']; - $this->uploadError( wfMsgExt( $error, 'parseinline' ) ); + if ( is_array( $details['error'] ) ) { # allow hooks to return error details in an array + $args = $details['error']; + $error = array_shift( $args ); + } else { + $error = $details['error']; + $args = null; + } + + $this->uploadError( wfMsgExt( $error, 'parseinline', $args ) ); break; default: throw new MWException( __METHOD__ . ": Unknown value `{$details['status']}`" ); -- 2.20.1