MediaWiki REL1_37
NewSectionMissingSummaryConstraint.php
Go to the documentation of this file.
1<?php
22
23use StatusValue;
24
33
35 private $userSummary;
36
39
41 private $result;
42
47 public function __construct(
48 string $userSummary,
50 ) {
51 $this->userSummary = $userSummary;
52 $this->allowBlankSummary = $allowBlankSummary;
53 }
54
55 public function checkConstraint(): string {
56 if ( !$this->allowBlankSummary && trim( $this->userSummary ) == '' ) {
57 // TODO this was == in EditPage, can it be === ?
58 $this->result = self::CONSTRAINT_FAILED;
59 } else {
60 $this->result = self::CONSTRAINT_PASSED;
61 }
62 return $this->result;
63 }
64
65 public function getLegacyStatus(): StatusValue {
66 $statusValue = StatusValue::newGood();
67 if ( $this->result === self::CONSTRAINT_FAILED ) {
68 // From EditPage, regarding the fatal:
69 // or 'missingcommentheader' if $section == 'new'. Blegh
70 $statusValue->fatal( 'missingsummary' );
71 $statusValue->value = self::AS_SUMMARY_NEEDED;
72 }
73 return $statusValue;
74 }
75
76}
if(ini_get('mbstring.func_overload')) if(!defined('MW_ENTRY_POINT'))
Pre-config setup: Before loading LocalSettings.php.
Definition Setup.php:88
For a new section, do not allow the user to post with an empty summary unless they choose to.
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.