mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-13 17:27:20 +00:00
79ec4ebf8b
Old_text and old_html were disabled a long time ago. With this patch, the user will get a custom error message if trying to use them (instead of the unrecognisedvar one), plus they'll stop appearing in /examine and /details, unless they were computed for the examined edit (and in that case, their description message is now restored). Lastly, added a precisation to their messages. Bug: T190698 Change-Id: Ife168522e6b1d8eb94ebbb8a16ae8831ec1dc497
48 lines
1.7 KiB
PHP
48 lines
1.7 KiB
PHP
<?php
|
|
|
|
// Exceptions that we might conceivably want to report to ordinary users
|
|
// (i.e. exceptions that don't represent bugs in the extension itself)
|
|
class AFPUserVisibleException extends AFPException {
|
|
/** @var string */
|
|
public $mExceptionID;
|
|
/** @var int */
|
|
public $mPosition;
|
|
/** @var array */
|
|
public $mParams;
|
|
|
|
/**
|
|
* @param string $exception_id
|
|
* @param int $position
|
|
* @param array $params
|
|
*/
|
|
public function __construct( $exception_id, $position, $params ) {
|
|
$this->mExceptionID = $exception_id;
|
|
$this->mPosition = $position;
|
|
$this->mParams = $params;
|
|
|
|
// Exception message text for logs should be in English.
|
|
$msg = $this->getMessageObj()->inLanguage( 'en' )->useDatabase( false )->text();
|
|
parent::__construct( $msg );
|
|
}
|
|
|
|
/**
|
|
* @return Message
|
|
*/
|
|
public function getMessageObj() {
|
|
// Give grep a chance to find the usages:
|
|
// abusefilter-exception-unexpectedatend, abusefilter-exception-expectednotfound
|
|
// abusefilter-exception-unrecognisedkeyword, abusefilter-exception-unexpectedtoken
|
|
// abusefilter-exception-unclosedstring, abusefilter-exception-invalidoperator
|
|
// abusefilter-exception-unrecognisedtoken, abusefilter-exception-noparams
|
|
// abusefilter-exception-dividebyzero, abusefilter-exception-unrecognisedvar
|
|
// abusefilter-exception-notenoughargs, abusefilter-exception-regexfailure
|
|
// abusefilter-exception-overridebuiltin, abusefilter-exception-outofbounds
|
|
// abusefilter-exception-notarray, abusefilter-exception-unclosedcomment
|
|
// abusefilter-exception-invalidiprange, abusefilter-exception-disabledvar
|
|
return wfMessage(
|
|
'abusefilter-exception-' . $this->mExceptionID,
|
|
$this->mPosition, ...$this->mParams
|
|
);
|
|
}
|
|
}
|