X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fexception%2FPermissionsError.php;h=e31374c2c7e470bfa6be63f71546f7e242667b50;hb=154b4383fe33aef9171dafa4350684cca36439a8;hp=bfba7b2742e7781350bfad365fe55689887ed7fe;hpb=a8304d4c73fd04c338ae23f3028fc475921cc0fa;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/exception/PermissionsError.php b/includes/exception/PermissionsError.php index bfba7b2742..e31374c2c7 100644 --- a/includes/exception/PermissionsError.php +++ b/includes/exception/PermissionsError.php @@ -28,21 +28,32 @@ class PermissionsError extends ErrorPageError { public $permission, $errors; - public function __construct( $permission, $errors = array() ) { + /** + * @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( - array( 'User', 'makeGroupLinkWiki' ), + [ 'User', 'makeGroupLinkWiki' ], User::getGroupsWithPermission( $this->permission ) ); if ( $groups ) { - $errors[] = array( 'badaccess-groups', $wgLang->commaList( $groups ), count( $groups ) ); + $errors[] = [ 'badaccess-groups', $wgLang->commaList( $groups ), count( $groups ) ]; } else { - $errors[] = array( 'badaccess-group0' ); + $errors[] = [ 'badaccess-group0' ]; } }