Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4151419
AuthorizationConstraint.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
AuthorizationConstraint.php
View Options
<?php
/**
* @license GPL-2.0-or-later
* @file
*/
namespace
MediaWiki\EditPage\Constraint
;
use
MediaWiki\Page\PageIdentity
;
use
MediaWiki\Permissions\Authority
;
use
MediaWiki\Permissions\PermissionStatus
;
use
StatusValue
;
/**
* Verify authorization to edit the page (user rights, rate limits, blocks).
*
* @since 1.44
* @internal
*/
class
AuthorizationConstraint
implements
IEditConstraint
{
private
PermissionStatus
$status
;
public
function
__construct
(
private
readonly
Authority
$performer
,
private
readonly
PageIdentity
$target
,
private
readonly
bool
$new
,
)
{
}
public
function
checkConstraint
():
string
{
$this
->
status
=
PermissionStatus
::
newEmpty
();
if
(
$this
->
new
&&
!
$this
->
performer
->
authorizeWrite
(
'create'
,
$this
->
target
,
$this
->
status
)
)
{
return
self
::
CONSTRAINT_FAILED
;
}
if
(
!
$this
->
performer
->
authorizeWrite
(
'edit'
,
$this
->
target
,
$this
->
status
)
)
{
return
self
::
CONSTRAINT_FAILED
;
}
return
self
::
CONSTRAINT_PASSED
;
}
public
function
getLegacyStatus
():
StatusValue
{
$statusValue
=
StatusValue
::
newGood
();
if
(
!
$this
->
status
->
isGood
()
)
{
// Report the most specific errors first
if
(
$this
->
status
->
isBlocked
()
)
{
$statusValue
->
setResult
(
false
,
self
::
AS_BLOCKED_PAGE_FOR_USER
);
}
elseif
(
$this
->
status
->
isRateLimitExceeded
()
)
{
$statusValue
->
setResult
(
false
,
self
::
AS_RATE_LIMITED
);
}
elseif
(
$this
->
status
->
getPermission
()
===
'create'
)
{
$statusValue
->
setResult
(
false
,
self
::
AS_NO_CREATE_PERMISSION
);
}
elseif
(
!
$this
->
performer
->
isRegistered
()
)
{
$statusValue
->
setResult
(
false
,
self
::
AS_READ_ONLY_PAGE_ANON
);
}
else
{
$statusValue
->
setResult
(
false
,
self
::
AS_READ_ONLY_PAGE_LOGGED
);
}
}
// TODO: Use error messages from the PermissionStatus ($this->status) here - T384399
return
$statusValue
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 19 2026, 19:57 (7 w, 14 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
49/92/df409384b2f3d5671b01d7622ad6
Default Alt Text
AuthorizationConstraint.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment