Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -1671,7 +1671,8 @@ |
1672 | 1672 | added to the descriptor |
1673 | 1673 | $descriptor: (array) the HTMLForm descriptor |
1674 | 1674 | |
1675 | | -'UploadVerification': additional chances to reject an uploaded file |
| 1675 | +'UploadVerification': additional chances to reject an uploaded file. Consider |
| 1676 | + using UploadVerifyFile instead. |
1676 | 1677 | string $saveName: destination file name |
1677 | 1678 | string $tempName: filesystem path to the temporary file for checks |
1678 | 1679 | string &$error: output: message key for message to show if upload canceled |
— | — | @@ -1679,6 +1680,16 @@ |
1680 | 1681 | is the message key and the remaining elements are used as parameters to |
1681 | 1682 | the message. |
1682 | 1683 | |
| 1684 | +'UploadVerifyFile': extra file verification, based on mime type, etc. Preferred |
| 1685 | + in most cases over UploadVerification. |
| 1686 | +object $upload: an instance of UploadBase, with all info about the upload |
| 1687 | +object $mime: the uploaded file's mime type, as detected by MediaWiki. Handlers |
| 1688 | + will typically only apply for specific mime types. |
| 1689 | +object &$error: output: true if the file is valid. Otherwise, and indexed array |
| 1690 | + representing the problem with the file, where the first element |
| 1691 | + is the message key and the remaining elements are used as parameters to |
| 1692 | + the message. |
| 1693 | + |
1683 | 1694 | 'UploadComplete': Upon completion of a file upload |
1684 | 1695 | $uploadBase: UploadBase (or subclass) object. File can be accessed by |
1685 | 1696 | $uploadBase->getLocalFile(). |
Index: trunk/phase3/includes/upload/UploadBase.php |
— | — | @@ -371,6 +371,12 @@ |
372 | 372 | if ( $virus ) { |
373 | 373 | return array( 'uploadvirus', $virus ); |
374 | 374 | } |
| 375 | + |
| 376 | + wfRunHooks( 'UploadVerifyFile', array( $this, $mime, &$status ) ); |
| 377 | + if ( $status !== true ) { |
| 378 | + return $status; |
| 379 | + } |
| 380 | + |
375 | 381 | wfDebug( __METHOD__ . ": all clear; passing.\n" ); |
376 | 382 | return true; |
377 | 383 | } |