MediaWiki master
ExistingSectionEditConstraint.php
Go to the documentation of this file.
1<?php
8
12
36
37 public function __construct(
38 private readonly string $section,
39 private readonly string $userSummary,
40 private readonly string $autoSummary,
41 private readonly bool $allowBlankSummary,
42 private readonly Content $newContent,
43 private readonly ?Content $originalContent,
44 private readonly string $submitButtonLabel,
45 ) {
46 }
47
48 public function checkConstraint(): EditPageStatus {
49 if ( $this->section === 'new' ) {
50 // Constraint is not applicable
52 }
53
54 if (
55 !$this->allowBlankSummary &&
56 !$this->newContent->equals( $this->originalContent ) &&
57 !$this->newContent->isRedirect() &&
58 md5( $this->userSummary ) === $this->autoSummary
59 ) {
61 ->setResult( false, self::AS_SUMMARY_NEEDED )
62 ->warning(
63 'missingsummary',
64 MessageValue::new( $this->submitButtonLabel )
65 );
66 }
67
69 }
70
71}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:69
Abstract class for all constraints that can prevent edits.
To simplify the logic in EditPage, this constraint may be created even if the section being edited do...
__construct(private readonly string $section, private readonly string $userSummary, private readonly string $autoSummary, private readonly bool $allowBlankSummary, private readonly Content $newContent, private readonly ?Content $originalContent, private readonly string $submitButtonLabel,)
Status returned by edit constraints and other page editing checks.
static newGood( $value=null)
Factory function for good results.
Value object representing a message for i18n.
Content objects represent page content, e.g.
Definition Content.php:28