allow UploadVerification hooks to return error details
authorDaniel Kinzler <daniel@users.mediawiki.org>
Fri, 13 Nov 2009 16:08:17 +0000 (16:08 +0000)
committerDaniel Kinzler <daniel@users.mediawiki.org>
Fri, 13 Nov 2009 16:08:17 +0000 (16:08 +0000)
docs/hooks.txt
includes/specials/SpecialUpload.php

index 45757b0..eeb7eac 100644 (file)
@@ -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
index 7f877ae..965c3bf 100644 (file)
@@ -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']}`" );