Manual:Hooks/UploadVerifyUpload

From MediaWiki.org
Jump to navigation Jump to search
UploadVerifyUpload
Available from version 1.28.0
Can be used to reject a file upload. Unlike 'UploadVerifyFile' it provides information about upload comment and the file description page, but does not run for uploads to stash.
Define function:
public static function onUploadVerifyUpload( UploadBase $upload, User $user, $props, $comment, $pageText, &$error ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"UploadVerifyUpload": "MyExtensionHooks::onUploadVerifyUpload"
	}
}

For MediaWiki ≤1.25:

$wgHooks['UploadVerifyUpload'][] = 'MyExtensionHooks::onUploadVerifyUpload';
Called from:File(s): UploadBase.php

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:UploadVerifyUpload extensions.

Upload verification, based on both file properties like ​MIME type (same as UploadVerifyFile) and the information entered by the user ​(upload comment, file page contents etc.).

Details[edit]

  • $upload: (object) An instance of UploadBase, with all info about the upload
  • ​$user: (object) An instance of User, the user uploading this file
  • $props: (array) File properties, as returned by FSFile::getPropsFromPath()
  • $comment: (string) Upload log comment (also used as edit summary)
  • $pageText: (string) File description page text (only used for new uploads)
  • &$error: output: If the file upload should be prevented, set this to the reason in the form of array( messagename, param1, param2, ... ) or a MessageSpecifier instance (you might want to use ApiMessage to provide machine-readable details for the API).

See also[edit]