A partial archive of https://discourse-mediawiki.wmflabs.org as of Saturday May 21, 2022.

Failed to create a new user group

bryandamon

I had the following in LocalSettings working to create a new user group that were able to upload additional filetypes but after upgrading to 1.28.2 from 1.26 it stopped working.

It does create the usergroup, however the new usergroup is not able to upload new filetypes. Any help would be appreciated.

## This allows a new group "FileAdmins" to upload certain filetypes (extensions)
$wgGroupPermissions['FileAdmins']['upload-additional'] = true;
$wgExtensionFunctions[] = function() {
	global $wgUser, $wgFileExtensions, $wgMaxUploadSize;
	$groups = $wgUser->getGroups();
	if ( in_array( 'FileAdmins', $groups ) ) {
		$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'pdf', 'tiff', 'bmp', 'webp', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx' );
		$wgMaxUploadSize = 1024*1024*10; # 10 MB max file size
		$wgUploadSizeWarning = 1024*1024*10; # 10 MB max file size for warning
	}
};
RazeSoldier

This variable is an array that stores functions to be called after most of MediaWiki initialization is complete. Note however that at this point the RequestContext is not yet fully set up, so attempting to use it (or equivalent globals such as $wgUser or $wgTitle) is liable to fail in odd ways. If you need to use the RequestContext, consider the BeforeInitialize and ApiBeforeMain hooks instead. – Manual:$wgExtensionFunctions

Try use hook.