Page MenuHomeWickedGov Phorge

MissingCommentConstraint.php
No OneTemporary

Size
917 B
Referenced Files
None
Subscribers
None

MissingCommentConstraint.php

<?php
/**
* @license GPL-2.0-or-later
* @file
*/
namespace MediaWiki\EditPage\Constraint;
use StatusValue;
/**
* Do not allow the user to post an empty comment (only used for new section)
*
* @since 1.36
* @internal
* @author DannyS712
*/
class MissingCommentConstraint implements IEditConstraint {
private bool $failed = false;
public function __construct(
private readonly string $section,
private readonly string $userComment,
) {
}
public function checkConstraint(): string {
if ( $this->section === 'new' && $this->userComment === '' ) {
$this->failed = true;
return self::CONSTRAINT_FAILED;
}
return self::CONSTRAINT_PASSED;
}
public function getLegacyStatus(): StatusValue {
$statusValue = StatusValue::newGood();
if ( $this->failed ) {
$statusValue->fatal( 'missingcommenttext' );
$statusValue->value = self::AS_TEXTBOX_EMPTY;
}
return $statusValue;
}
}

File Metadata

Mime Type
text/x-php
Expires
Wed, Aug 19, 08:05 (2 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
e6/ed/569b35729d2e84da167b8731c874
Default Alt Text
MissingCommentConstraint.php (917 B)

Event Timeline