MediaWiki master
SimpleAntiSpamConstraint.php
Go to the documentation of this file.
1<?php
8
12use Psr\Log\LoggerInterface;
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(): PageEditStatus {
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 PageEditStatus::newFatal( 'spamprotectionmatch', '' )
47 ->setValue( self::AS_SPAM_ERROR );
48 }
49 return PageEditStatus::newGood();
50 }
51
52}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:69
Abstract class for all constraints that can prevent edits.
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,)
Status returned by edit constraints and other page editing checks.
setValue(int $value)
Sets the value of the status.
Represents a title within MediaWiki.
Definition Title.php:69
Interface for objects representing user identity.