50 public function __construct( ?
string $permission, $status = [] ) {
51 $this->deprecatePublicProperty(
'permission',
'1.43' );
52 $this->deprecatePublicPropertyFallback(
'errors',
'1.43',
54 return $this->status->toLegacyErrorArray();
56 function ( $errors ) {
57 $this->status = PermissionStatus::newEmpty();
58 foreach ( $errors as $error ) {
59 if ( is_array( $error ) ) {
61 $this->status->fatal( ...$error );
63 $this->status->fatal( $error );
69 if ( is_array( $status ) ) {
71 $status = PermissionStatus::newEmpty();
72 foreach ( $errors as $error ) {
73 if ( is_array( $error ) ) {
75 $status->
fatal( ...$error );
77 $status->
fatal( $error );
81 throw new \InvalidArgumentException( __METHOD__ .
82 ': $status must be PermissionStatus or array, got ' . get_debug_type( $status ) );
85 if ( $permission ===
null && $status->
isGood() ) {
86 throw new \InvalidArgumentException( __METHOD__ .
87 ': $permission and $status cannot both be empty' );
90 $this->permission = $permission;
93 $status = MediaWikiServices::getInstance()
94 ->getPermissionManager()
96 ->newFatalPermissionDeniedStatus( $this->permission, RequestContext::getMain() );
99 $this->status = $status;
102 parent::__construct(
'permissionserrors', $status->
getMessages()[0] );