MediaWiki REL1_40
MissingCommentConstraint.php
Go to the documentation of this file.
1<?php
22
23use StatusValue;
24
33
35 private $userComment;
36
40 public function __construct( string $userComment ) {
41 $this->userComment = $userComment;
42 }
43
44 public function checkConstraint(): string {
45 if ( $this->userComment == '' ) {
46 // TODO this was == in EditPage, can it be === ?
47 return self::CONSTRAINT_FAILED;
48 }
49 return self::CONSTRAINT_PASSED;
50 }
51
52 public function getLegacyStatus(): StatusValue {
53 $statusValue = StatusValue::newGood();
54 if ( $this->userComment == '' ) {
55 $statusValue->fatal( 'missingcommenttext' );
56 $statusValue->value = self::AS_TEXTBOX_EMPTY;
57 }
58 return $statusValue;
59 }
60
61}
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
Definition WebStart.php:88
Do not allow the user to post an empty comment (only used for new section)
getLegacyStatus()
Get the legacy status for failure (or success)
Generic operation result class Has warning/error list, boolean status and arbitrary value.
fatal( $message,... $parameters)
Add an error and set OK to false, indicating that the operation as a whole was fatal.
Interface for all constraints that can prevent edits.