10use MediaWiki\Debug\DeprecationHelper;
24 use DeprecationHelper;
26 private ?
string $permission;
37 public function __construct( ?
string $permission, $status = [] ) {
38 $this->deprecatePublicProperty(
'permission',
'1.43' );
40 if ( is_array( $status ) ) {
42 $status = PermissionStatus::newEmpty();
43 foreach ( $errors as $error ) {
44 if ( is_array( $error ) ) {
46 $status->
fatal( ...$error );
48 $status->
fatal( $error );
52 throw new \InvalidArgumentException( __METHOD__ .
53 ': $status must be PermissionStatus or array, got ' . get_debug_type( $status ) );
56 if ( $permission ===
null && $status->
isGood() ) {
57 throw new \InvalidArgumentException( __METHOD__ .
58 ': $permission and $status cannot both be empty' );
61 $this->permission = $permission;
65 ->getPermissionManager()
67 ->newFatalPermissionDeniedStatus( $this->permission, RequestContext::getMain() );
70 $this->status = $status;
73 parent::__construct(
'permissionserrors', $status->
getMessages()[0] );
77 public function report( $action = self::SEND_OUTPUT ) {
80 $wgOut->showPermissionStatus( $this->status, $this->permission );
81 if ( $action === self::SEND_OUTPUT ) {
88class_alias( PermissionsError::class,
'PermissionsError' );
if(MW_ENTRY_POINT==='index') if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli' $wgOut
Group all the pieces relevant to the context of a request into one instance.
An error page which can definitely be safely rendered using the OutputPage.
getMessages(?string $type=null)
Returns a list of error messages, optionally only those of the given type.
fatal( $message,... $parameters)
Add an error and set OK to false, indicating that the operation as a whole was fatal.
isGood()
Returns whether the operation completed and didn't have any error or warnings.