toLegacyErrorArray(); } if ( $permission === null && !$errors ) { throw new \InvalidArgumentException( __METHOD__ . ': $permission and $errors cannot both be empty' ); } $this->permission = $permission; if ( !count( $errors ) ) { $groups = []; foreach ( MediaWikiServices::getInstance() ->getGroupPermissionsLookup() // @phan-suppress-next-line PhanTypeMismatchArgumentNullable Null on permission is check when used here ->getGroupsWithPermission( $this->permission ) as $group ) { $groups[] = UserGroupMembership::getLink( $group, RequestContext::getMain(), 'wiki' ); } if ( $groups ) { $errors[] = [ 'badaccess-groups', Message::listParam( $groups, 'comma' ), count( $groups ) ]; } else { $errors[] = [ 'badaccess-group0' ]; } } $this->errors = $errors; // Give the parent class something to work with parent::__construct( 'permissionserrors', Message::newFromSpecifier( $errors[0] ) ); } public function report( $action = self::SEND_OUTPUT ) { global $wgOut; $wgOut->showPermissionsErrorPage( $this->errors, $this->permission ); if ( $action === self::SEND_OUTPUT ) { $wgOut->output(); } } }