MediaWiki REL1_39
SimpleAntiSpamConstraint.php
Go to the documentation of this file.
1<?php
22
24use Psr\Log\LoggerInterface;
25use StatusValue;
26use Title;
27
35
37 private $logger;
38
40 private $input;
41
43 private $user;
44
46 private $title;
47
54 public function __construct(
55 LoggerInterface $logger,
56 string $inputText,
57 UserIdentity $user,
58 Title $title
59 ) {
60 $this->logger = $logger;
61 $this->input = $inputText;
62 $this->user = $user;
63 $this->title = $title;
64 }
65
66 public function checkConstraint(): string {
67 if ( $this->input === '' ) {
68 return self::CONSTRAINT_PASSED;
69 }
70 $this->logger->debug(
71 '{name} editing "{title}" submitted bogus field "{input}"',
72 [
73 'name' => $this->user->getName(),
74 'title' => $this->title->getPrefixedText(),
75 'input' => $this->input
76 ]
77 );
78 return self::CONSTRAINT_FAILED;
79 }
80
81 public function getLegacyStatus(): StatusValue {
82 $statusValue = StatusValue::newGood();
83 if ( $this->input !== '' ) {
84 $statusValue->fatal( 'spamprotectionmatch', false );
85 $statusValue->value = self::AS_SPAM_ERROR;
86 }
87 return $statusValue;
88 }
89
90}
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
Definition WebStart.php:82
Verify simple anti spam measure of an extra hidden text field.
getLegacyStatus()
Get the legacy status for failure (or success)
__construct(LoggerInterface $logger, string $inputText, UserIdentity $user, Title $title)
Generic operation result class Has warning/error list, boolean status and arbitrary value.
fatal( $message,... $parameters)
Add an error and set OK to false, indicating that the operation as a whole was fatal.
Represents a title within MediaWiki.
Definition Title.php:49
Interface for all constraints that can prevent edits.
Interface for objects representing user identity.