| 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 "UploadStashFile" to register handlers implementing this interface. |
| 12 | * |
| 13 | * @stable to implement |
| 14 | * @ingroup Hooks |
| 15 | */ |
| 16 | interface UploadStashFileHook { |
| 17 | /** |
| 18 | * This hook is called before a file is stashed (uploaded to stash). |
| 19 | * Note that code which has not been updated for MediaWiki 1.28 may not call this |
| 20 | * hook. If your extension absolutely, positively must prevent some files from |
| 21 | * being uploaded, use UploadVerifyFile or UploadVerifyUpload. |
| 22 | * |
| 23 | * @since 1.35 |
| 24 | * |
| 25 | * @param UploadBase $upload Instance of UploadBase with all info about the upload |
| 26 | * @param User $user User uploading this file |
| 27 | * @param array|null $props File properties, as returned by MWFileProps::getPropsFromPath(). |
| 28 | * Note this is not always guaranteed to be set, e.g. in test scenarios. Call |
| 29 | * MWFileProps::getPropsFromPath() yourself in case you need the information. |
| 30 | * @param array|MessageSpecifier|null &$error Output: If the file stashing should |
| 31 | * be prevented, set this to the reason in the form of [ messagename, param1, param2, ... ] |
| 32 | * or a MessageSpecifier instance. (You might want to use ApiMessage to provide machine |
| 33 | * -readable details for the API.) |
| 34 | * @return bool|void True or no return value to continue or false to abort |
| 35 | */ |
| 36 | public function onUploadStashFile( UploadBase $upload, User $user, ?array $props, &$error ); |
| 37 | } |