| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Hook; |
| 4 | |
| 5 | use MediaWiki\User\User; |
| 6 | use UploadBase; |
| 7 | use Wikimedia\Message\MessageSpecifier; |
| 8 | |
| 9 | /** |
| 10 | * This is a hook handler interface, see docs/Hooks.md. |
| 11 | * Use the hook name "UploadVerifyUpload" to register handlers implementing this interface. |
| 12 | * |
| 13 | * @stable to implement |
| 14 | * @ingroup Hooks |
| 15 | */ |
| 16 | interface UploadVerifyUploadHook { |
| 17 | /** |
| 18 | * Use this hook to perform upload verification, based on both file properties like |
| 19 | * MIME type (same as UploadVerifyFile) and the information entered by the user |
| 20 | * (upload comment, file page contents etc.). |
| 21 | * |
| 22 | * @since 1.35 |
| 23 | * |
| 24 | * @param UploadBase $upload Instance of UploadBase, with all info about the upload |
| 25 | * @param User $user User uploading this file |
| 26 | * @param array|null $props File properties, as returned by MWFileProps::getPropsFromPath(). |
| 27 | * Note this is not always guaranteed to be set, e.g. in test scenarios. |
| 28 | * Call MWFileProps::getPropsFromPath() yourself in case you need the information. |
| 29 | * @param string $comment Upload log comment (also used as edit summary) |
| 30 | * @param string|false $pageText File description page text (only used for new uploads) |
| 31 | * @param array|MessageSpecifier|null &$error Output: If the file upload should be |
| 32 | * prevented, set this to the reason in the form of [ messagename, param1, param2, ... ] |
| 33 | * or a MessageSpecifier instance. (You might want to use ApiMessage to |
| 34 | * provide machine-readable details for the API.) |
| 35 | * @return bool|void True or no return value to continue or false to abort |
| 36 | */ |
| 37 | public function onUploadVerifyUpload( UploadBase $upload, User $user, ?array $props, $comment, |
| 38 | $pageText, &$error |
| 39 | ); |
| 40 | } |