* @file
*/
+use MediaWiki\MediaWikiServices;
+
/**
* Show an error when a user tries to do something they do not have the necessary
* permissions for.
$this->permission = $permission;
if ( !count( $errors ) ) {
- $groups = array_map(
- [ 'User', 'makeGroupLinkWiki' ],
- User::getGroupsWithPermission( $this->permission )
- );
+ $groups = [];
+ foreach ( MediaWikiServices::getInstance()
+ ->getPermissionManager()
+ ->getGroupsWithPermission( $this->permission ) as $group ) {
+ $groups[] = UserGroupMembership::getLink( $group, RequestContext::getMain(), 'wiki' );
+ }
if ( $groups ) {
$errors[] = [ 'badaccess-groups', $wgLang->commaList( $groups ), count( $groups ) ];
parent::__construct( 'permissionserrors', Message::newFromSpecifier( $errors[0] ) );
}
- public function report() {
+ public function report( $action = self::SEND_OUTPUT ) {
global $wgOut;
$wgOut->showPermissionsErrorPage( $this->errors, $this->permission );
- $wgOut->output();
+ if ( $action === self::SEND_OUTPUT ) {
+ $wgOut->output();
+ }
}
}