MediaWiki master
SimpleAntiSpamConstraint.php
Go to the documentation of this file.
1<?php
8
11use Psr\Log\LoggerInterface;
12use StatusValue;
13
21
28 public function __construct(
29 private readonly LoggerInterface $logger,
30 private readonly string $input,
31 private readonly UserIdentity $user,
32 private readonly Title $title,
33 ) {
34 }
35
36 public function checkConstraint(): StatusValue {
37 if ( $this->input !== '' ) {
38 $this->logger->debug(
39 '{name} editing "{title}" submitted bogus field "{input}"',
40 [
41 'name' => $this->user->getName(),
42 'title' => $this->title->getPrefixedText(),
43 'input' => $this->input
44 ]
45 );
46 return StatusValue::newGood( self::AS_SPAM_ERROR )
47 ->fatal( 'spamprotectionmatch', '' );
48 }
49 return StatusValue::newGood();
50 }
51
52}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:68
Verify simple anti spam measure of an extra hidden text field.
__construct(private readonly LoggerInterface $logger, private readonly string $input, private readonly UserIdentity $user, private readonly Title $title,)
Represents a title within MediaWiki.
Definition Title.php:69
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Interface for all constraints that can prevent edits.
Interface for objects representing user identity.