49 public function __construct( ?
string $permission, $status = [] ) {
50 $this->deprecatePublicProperty(
'permission',
'1.43' );
51 $this->deprecatePublicPropertyFallback(
'errors',
'1.43',
53 return $this->status->toLegacyErrorArray();
55 function ( $errors ) {
56 $this->status = PermissionStatus::newEmpty();
57 foreach ( $errors as $error ) {
58 if ( is_array( $error ) ) {
60 $this->status->fatal( ...$error );
62 $this->status->fatal( $error );
68 if ( is_array( $status ) ) {
70 $status = PermissionStatus::newEmpty();
71 foreach ( $errors as $error ) {
72 if ( is_array( $error ) ) {
74 $status->
fatal( ...$error );
76 $status->
fatal( $error );
80 throw new \InvalidArgumentException( __METHOD__ .
81 ': $status must be PermissionStatus or array, got ' . get_debug_type( $status ) );
84 if ( $permission ===
null && $status->
isGood() ) {
85 throw new \InvalidArgumentException( __METHOD__ .
86 ': $permission and $status cannot both be empty' );
89 $this->permission = $permission;
92 $status = MediaWikiServices::getInstance()
93 ->getPermissionManager()
95 ->newFatalPermissionDeniedStatus( $this->permission, RequestContext::getMain() );
98 $this->status = $status;
101 parent::__construct(
'permissionserrors', $status->
getMessages()[0] );