X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fexception%2FPermissionsError.php;h=cc69a762c1195ee1c1a56d845a8678a936cb633b;hp=bd0b1204d463167275d34ea69aeb0e914564b09e;hb=49748181dd56ec97e7ba7c13e684a16abceb3cc0;hpb=a5be382adfdad4678eec18413c6a118cb3284daf diff --git a/includes/exception/PermissionsError.php b/includes/exception/PermissionsError.php index bd0b1204d4..cc69a762c1 100644 --- a/includes/exception/PermissionsError.php +++ b/includes/exception/PermissionsError.php @@ -29,19 +29,26 @@ class PermissionsError extends ErrorPageError { public $permission, $errors; /** - * @param string $permission A permission name. - * @param string[] $errors Error message keys + * @param string|null $permission A permission name or null if unknown + * @param array $errors Error message keys or [key, param...] arrays; must not be empty if + * $permission is null + * @throws \InvalidArgumentException */ public function __construct( $permission, $errors = [] ) { global $wgLang; + if ( $permission === null && !$errors ) { + throw new \InvalidArgumentException( __METHOD__ . + ': $permission and $errors cannot both be empty' ); + } + $this->permission = $permission; if ( !count( $errors ) ) { - $groups = array_map( - [ 'User', 'makeGroupLinkWiki' ], - User::getGroupsWithPermission( $this->permission ) - ); + $groups = []; + foreach ( User::getGroupsWithPermission( $this->permission ) as $group ) { + $groups[] = UserGroupMembership::getLink( $group, RequestContext::getMain(), 'wiki' ); + } if ( $groups ) { $errors[] = [ 'badaccess-groups', $wgLang->commaList( $groups ), count( $groups ) ]; @@ -51,6 +58,9 @@ class PermissionsError extends ErrorPageError { } $this->errors = $errors; + + // Give the parent class something to work with + parent::__construct( 'permissionserrors', Message::newFromSpecifier( $errors[0] ) ); } public function report() {