MediaWiki master
NewSectionMissingSubjectConstraint.php
Go to the documentation of this file.
1<?php
6
7namespace MediaWiki\EditPage\Constraint;
8
9use MediaWiki\PageEdit\PageEditAttemptState;
10use MediaWiki\PageEdit\PageEditStatus;
11
20
21 public function __construct(
22 private readonly string $section,
23 private readonly string $subject,
24 private readonly bool $forceEditSummary,
25 private readonly PageEditAttemptState $editAttemptState,
26 ) {
27 }
28
29 public function checkConstraint(): PageEditStatus {
30 if ( $this->section === 'new' &&
31 $this->forceEditSummary &&
32 !$this->editAttemptState->shouldAllowBlankSummary() &&
33 trim( $this->subject ) === ''
34 ) {
35 $this->editAttemptState->setAllowBlankSummary( true );
36 return PageEditStatus::newGood( self::AS_SUMMARY_NEEDED )
37 ->setOK( false )
38 ->setCanResubmit( true )
39 ->warning( 'edit-constraint-newsectionmissingsubject-warning' );
40 }
41
42 return PageEditStatus::newGood();
43 }
44
45}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:72
Abstract class for all constraints that can prevent edits.
For a new section, do not allow the user to post with an empty subject (section title) unless they ch...
__construct(private readonly string $section, private readonly string $subject, private readonly bool $forceEditSummary, private readonly PageEditAttemptState $editAttemptState,)
Data returned by an edit attempt that can be passed to the next one to allow bypassing certain warnin...
Status returned by edit constraints and other page editing checks.