Hello,
I am working on a custom extension that would only allow admin users to upload video files, the extension is enabled and appears under Special:Version. The permission also appears under the correct category under Special:ListGroupRights.
However, when I attempt to upload a video (mp4) under Special:Upload, it goes through.
I just enabled error reporting / showExceptionDetails / debugToolbar / ShowDebug / DevelopmentWarnings and added print statements to my extension file, but I am not seeing any indicators that it's trying to work but is failing.
I am hoping somebody could point me in the right direction on how to debug this more efficiently or offer insight into the problem. Thank you for your time and expertise.
In the PHP file:
namespace MediaWiki\Extension\VideoPermissions;
use MediaWiki\Hook\UploadVerifyUploadHook;
use User;
use UploadBase;
class PermissionCheck implements UploadVerifyUploadHook {
public function onUploadVerifyUpload (UploadBase $upload, User $user, ?array $props, $comment, $pageText, &$error) {
$file = $upload->getLocalFile();
if ($file->getMediaType() !== MEDIATYPE_VIDEO) {
return;
} else {
$title = $upload->getTitle();
if ($user->definitelyCan('videopermission-allow', $title)) {
} else {
$error = 'videopermission-no-perm-to-upload';
return false;
}}}
in the extension.json file:
"AvailableRights": ["videopermissions-allow"],
"GroupPermissions": {"sysop": {
"videopermissions-allow": true
}},
"Hooks": {"UploadVerifyUpload": "main"
},
"HookHandlers": {"main": {
"class": "\\MediaWiki\\Extension\\VideoPermissions\\PermissionCheck"
}},