MediaWiki
REL1_39
AutoSummaryMissingSummaryConstraint.php
Go to the documentation of this file.
1
<?php
21
namespace
MediaWiki\EditPage\Constraint
;
22
23
use
Content
;
24
use
StatusValue
;
25
41
class
AutoSummaryMissingSummaryConstraint
implements
IEditConstraint
{
42
44
private
$userSummary;
45
47
private
$autoSummary;
48
50
private
$allowBlankSummary;
51
53
private
$newContent;
54
56
private
$originalContent;
57
59
private
$result;
60
68
public
function
__construct
(
69
string
$userSummary,
70
string
$autoSummary,
71
bool
$allowBlankSummary,
72
Content
$newContent,
73
Content
$originalContent
74
) {
75
$this->userSummary = $userSummary;
76
$this->autoSummary = $autoSummary;
77
$this->allowBlankSummary = $allowBlankSummary;
78
$this->newContent = $newContent;
79
$this->originalContent = $originalContent;
80
}
81
82
public
function
checkConstraint
(): string {
83
if
(
84
!$this->allowBlankSummary &&
85
!$this->newContent->equals( $this->originalContent ) &&
86
!$this->newContent->isRedirect() &&
87
md5( $this->userSummary ) == $this->autoSummary
88
) {
89
// TODO this was == in EditPage, can it be === ?
90
$this->result = self::CONSTRAINT_FAILED;
91
}
else
{
92
$this->result = self::CONSTRAINT_PASSED;
93
}
94
return
$this->result;
95
}
96
97
public
function
getLegacyStatus
():
StatusValue
{
98
$statusValue =
StatusValue
::newGood();
99
if
( $this->result === self::CONSTRAINT_FAILED ) {
100
$statusValue->
fatal
(
'missingsummary'
);
101
$statusValue->value = self::AS_SUMMARY_NEEDED;
102
}
103
return
$statusValue;
104
}
105
106
}
if
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
Definition
WebStart.php:82
MediaWiki\EditPage\Constraint\AutoSummaryMissingSummaryConstraint
For an edit to an existing page but not with a new section, do not allow the user to post with a summ...
Definition
AutoSummaryMissingSummaryConstraint.php:41
MediaWiki\EditPage\Constraint\AutoSummaryMissingSummaryConstraint\__construct
__construct(string $userSummary, string $autoSummary, bool $allowBlankSummary, Content $newContent, Content $originalContent)
Definition
AutoSummaryMissingSummaryConstraint.php:68
MediaWiki\EditPage\Constraint\AutoSummaryMissingSummaryConstraint\getLegacyStatus
getLegacyStatus()
Get the legacy status for failure (or success)
Definition
AutoSummaryMissingSummaryConstraint.php:97
MediaWiki\EditPage\Constraint\AutoSummaryMissingSummaryConstraint\checkConstraint
checkConstraint()
Definition
AutoSummaryMissingSummaryConstraint.php:82
StatusValue
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition
StatusValue.php:46
StatusValue\fatal
fatal( $message,... $parameters)
Add an error and set OK to false, indicating that the operation as a whole was fatal.
Definition
StatusValue.php:276
Content
Base interface for content objects.
Definition
Content.php:35
MediaWiki\EditPage\Constraint\IEditConstraint
Interface for all constraints that can prevent edits.
Definition
IEditConstraint.php:33
MediaWiki\EditPage\Constraint
Definition
AccidentalRecreationConstraint.php:21
includes
editpage
Constraint
AutoSummaryMissingSummaryConstraint.php
Generated on Fri Dec 20 2024 15:34:11 for MediaWiki by
1.10.0