MediaWiki
master
MissingCommentConstraint.php
Go to the documentation of this file.
1
<?php
7
namespace
MediaWiki\EditPage\Constraint
;
8
9
use
StatusValue
;
10
18
class
MissingCommentConstraint
implements
IEditConstraint
{
19
20
private
bool
$failed =
false
;
21
22
public
function
__construct
(
23
private
readonly
string
$section,
24
private
readonly
string
$userComment,
25
) {
26
}
27
28
public
function
checkConstraint
(): string {
29
if
( $this->section ===
'new'
&& $this->userComment ===
''
) {
30
$this->failed =
true
;
31
return
self::CONSTRAINT_FAILED;
32
}
33
return
self::CONSTRAINT_PASSED;
34
}
35
36
public
function
getLegacyStatus
():
StatusValue
{
37
$statusValue =
StatusValue
::newGood();
38
if
( $this->failed ) {
39
$statusValue->
fatal
(
'missingcommenttext'
);
40
$statusValue->value = self::AS_TEXTBOX_EMPTY;
41
}
42
return
$statusValue;
43
}
44
45
}
if
if(!defined('MW_SETUP_CALLBACK'))
Definition
WebStart.php:68
MediaWiki\EditPage\Constraint\MissingCommentConstraint
Do not allow the user to post an empty comment (only used for new section)
Definition
MissingCommentConstraint.php:18
MediaWiki\EditPage\Constraint\MissingCommentConstraint\__construct
__construct(private readonly string $section, private readonly string $userComment,)
Definition
MissingCommentConstraint.php:22
MediaWiki\EditPage\Constraint\MissingCommentConstraint\checkConstraint
checkConstraint()
Definition
MissingCommentConstraint.php:28
MediaWiki\EditPage\Constraint\MissingCommentConstraint\getLegacyStatus
getLegacyStatus()
Get the legacy status for failure (or success)
Definition
MissingCommentConstraint.php:36
StatusValue
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition
StatusValue.php:41
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:288
MediaWiki\EditPage\Constraint\IEditConstraint
Interface for all constraints that can prevent edits.
Definition
IEditConstraint.php:19
MediaWiki\EditPage\Constraint
Definition
AccidentalRecreationConstraint.php:7
includes
EditPage
Constraint
MissingCommentConstraint.php
Generated on Thu Jan 15 2026 16:24:15 for MediaWiki by
1.10.0