From: Daniel Kinzler Date: Fri, 13 Nov 2009 16:08:17 +0000 (+0000) Subject: allow UploadVerification hooks to return error details X-Git-Tag: 1.31.0-rc.0~38826 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=ee0cbd5dcac80ba02f037ad6ff1970892ffd7ee8;p=lhc%2Fweb%2Fwiklou.git allow UploadVerification hooks to return error details --- 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']}`" );