MediaWiki REL1_37
AutoSummaryMissingSummaryConstraint.php
Go to the documentation of this file.
1<?php
22
23use Content;
24use StatusValue;
25
42
44 private $userSummary;
45
47 private $autoSummary;
48
51
53 private $newContent;
54
57
59 private $result;
60
68 public function __construct(
69 string $userSummary,
70 string $autoSummary,
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(ini_get('mbstring.func_overload')) if(!defined('MW_ENTRY_POINT'))
Pre-config setup: Before loading LocalSettings.php.
Definition Setup.php:88
For an edit to an existing page but not with a new section, do not allow the user to post with a summ...
__construct(string $userSummary, string $autoSummary, bool $allowBlankSummary, Content $newContent, Content $originalContent)
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.
Base interface for content objects.
Definition Content.php:35
Interface for all constraints that can prevent edits.