MediaWiki
master
Toggle main menu visibility
RevisionDeletedConstraint.php
Go to the documentation of this file.
1
<?php
2
3
namespace
MediaWiki\EditPage\Constraint;
4
5
use MediaWiki\PageEdit\PageEditAttemptState;
6
use MediaWiki\PageEdit\PageEditStatus;
7
use MediaWiki\Permissions\Authority;
8
use MediaWiki\Revision\RevisionRecord;
9
use MediaWiki\Revision\RevisionStoreRecord;
10
use MediaWiki\Title\Title;
11
19
class
RevisionDeletedConstraint
extends
EditConstraint
{
20
21
public
function
__construct
(
22
private
readonly
PageEditAttemptState
$editAttemptState,
23
private
readonly
int
$oldId,
24
private
readonly ?
RevisionRecord
$revisionRecord,
25
private
readonly
string
$section,
26
private
readonly
Title
$title,
27
private
readonly
Authority
$authority,
28
) {
29
}
30
34
public
function
checkConstraint
():
PageEditStatus
{
35
if
( $this->section ===
'new'
) {
36
return
PageEditStatus::newGood();
37
}
38
39
if
( $this->revisionRecord instanceof
RevisionStoreRecord
) {
40
if
( !$this->revisionRecord->userCan( RevisionRecord::DELETED_TEXT, $this->authority ) ) {
41
return
PageEditStatus::newFatal(
'rev-deleted-text-permission'
, $this->title->getPrefixedURL() )
42
->setValue( self::AS_REVISION_WAS_DELETED );
43
} elseif ( $this->revisionRecord->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
44
// Let sysop know that this will make private content public if saved
45
$status = PageEditStatus::newGood( self::AS_REVISION_WAS_DELETED )
46
->setOK( $this->editAttemptState->shouldIgnoreRevisionDeletedWarning() );
47
$this->editAttemptState->setIgnoreRevisionDeletedWarning(
true
);
48
return
$status
49
->warning(
'rev-deleted-text-view'
, $this->title->getPrefixedURL() )
50
->setCanResubmit(
true
);
51
}
52
} elseif ( $this->title->exists() ) {
53
// Something went wrong, and the revision is missing
54
return
PageEditStatus::newFatal(
'missing-revision'
, $this->oldId )
55
->setValue( self::AS_REVISION_MISSING );
56
}
57
58
return
PageEditStatus::newGood();
59
}
60
}
if
if(!defined('MW_SETUP_CALLBACK'))
Definition
WebStart.php:72
MediaWiki\EditPage\Constraint\EditConstraint
Abstract class for all constraints that can prevent edits.
Definition
EditConstraint.php:18
MediaWiki\EditPage\Constraint\RevisionDeletedConstraint
This constraint is used to display an error if the user loses access to the revision while editing it...
Definition
RevisionDeletedConstraint.php:19
MediaWiki\EditPage\Constraint\RevisionDeletedConstraint\checkConstraint
checkConstraint()
PageEditStatus A status indicating failure or success. A status that is not OK indicates a failure an...
Definition
RevisionDeletedConstraint.php:34
MediaWiki\EditPage\Constraint\RevisionDeletedConstraint\__construct
__construct(private readonly PageEditAttemptState $editAttemptState, private readonly int $oldId, private readonly ?RevisionRecord $revisionRecord, private readonly string $section, private readonly Title $title, private readonly Authority $authority,)
Definition
RevisionDeletedConstraint.php:21
MediaWiki\PageEdit\PageEditAttemptState
Data returned by an edit attempt that can be passed to the next one to allow bypassing certain warnin...
Definition
PageEditAttemptState.php:14
MediaWiki\PageEdit\PageEditStatus
Status returned by edit constraints and other page editing checks.
Definition
PageEditStatus.php:19
MediaWiki\Revision\RevisionRecord
Page revision base class.
Definition
RevisionRecord.php:35
MediaWiki\Revision\RevisionStoreRecord
A RevisionRecord representing an existing revision persisted in the revision table.
Definition
RevisionStoreRecord.php:28
MediaWiki\Title\Title
Represents a title within MediaWiki.
Definition
Title.php:69
MediaWiki\Permissions\Authority
This interface represents the authority associated with the current execution context,...
Definition
Authority.php:23
includes
EditPage
Constraint
RevisionDeletedConstraint.php
Generated on
for MediaWiki by
1.18.0