From a1130bb205ab7426b807ebfcf610dc6bcdf33941 Mon Sep 17 00:00:00 2001 From: Daniel Kinzler Date: Mon, 30 Aug 2010 12:10:02 +0000 Subject: [PATCH] interoduced new hoop in Uploadbase::verifyFile, as per comments to r71789 --- docs/hooks.txt | 13 ++++++++++++- includes/upload/UploadBase.php | 6 ++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index d414145f50..f1bf5125b0 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1671,7 +1671,8 @@ $descriptor: (array) the HTMLForm descriptor added to the descriptor $descriptor: (array) the HTMLForm descriptor -'UploadVerification': additional chances to reject an uploaded file +'UploadVerification': additional chances to reject an uploaded file. Consider + using UploadVerifyFile instead. string $saveName: destination file name string $tempName: filesystem path to the temporary file for checks string &$error: output: message key for message to show if upload canceled @@ -1679,6 +1680,16 @@ string &$error: output: message key for message to show if upload canceled is the message key and the remaining elements are used as parameters to the message. +'UploadVerifyFile': extra file verification, based on mime type, etc. Preferred + in most cases over UploadVerification. +object $upload: an instance of UploadBase, with all info about the upload +object $mime: the uploaded file's mime type, as detected by MediaWiki. Handlers + will typically only apply for specific mime types. +object &$error: output: true if the file is valid. Otherwise, and indexed array + representing the problem with the file, 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 $uploadBase->getLocalFile(). diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index 1e23fbeb5b..aa47e1097b 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -371,6 +371,12 @@ abstract class UploadBase { if ( $virus ) { return array( 'uploadvirus', $virus ); } + + wfRunHooks( 'UploadVerifyFile', array( $this, $mime, &$status ) ); + if ( $status !== true ) { + return $status; + } + wfDebug( __METHOD__ . ": all clear; passing.\n" ); return true; } -- 2.20.1