mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-27 23:40:19 +00:00
AFPUserVisibleException should log in English, not the user's language
The user's language should only be used when the exception is actually displayed to the user. This will also avoid "User::loadFromSession called before the end of Setup.php" warnings when the syntax error is encountered during filter execution for account autocreation, where we don't display it to the user. Bug: T124367 Change-Id: Ic17f56aecbe575ef15c6970c4298f889249e1904
This commit is contained in:
parent
106ce2235f
commit
8ee834c376
|
@ -536,12 +536,26 @@ class AFPException extends MWException {
|
|||
// 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 {
|
||||
public $mExceptionId;
|
||||
public $mPosition;
|
||||
public $mParams;
|
||||
|
||||
/**
|
||||
* @param string $exception_id
|
||||
* @param int $position
|
||||
* @param array $params
|
||||
*/
|
||||
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 );
|
||||
}
|
||||
|
||||
public function getMessageObj() {
|
||||
// Give grep a chance to find the usages:
|
||||
// abusefilter-exception-unexpectedatend, abusefilter-exception-expectednotfound
|
||||
// abusefilter-exception-unrecognisedkeyword, abusefilter-exception-unexpectedtoken
|
||||
|
@ -551,15 +565,10 @@ class AFPUserVisibleException extends AFPException {
|
|||
// abusefilter-exception-notenoughargs, abusefilter-exception-regexfailure
|
||||
// abusefilter-exception-overridebuiltin, abusefilter-exception-outofbounds
|
||||
// abusefilter-exception-notlist
|
||||
$msg = wfMessage(
|
||||
'abusefilter-exception-' . $exception_id,
|
||||
array_merge( array( $position ), $params )
|
||||
)->text();
|
||||
parent::__construct( $msg );
|
||||
|
||||
$this->mExceptionID = $exception_id;
|
||||
$this->mPosition = $position;
|
||||
$this->mParams = $params;
|
||||
return wfMessage(
|
||||
'abusefilter-exception-' . $this->mExceptionID,
|
||||
array_merge( array( $this->mPosition ), $this->mParams )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -646,7 +655,7 @@ class AbuseFilterParser {
|
|||
} catch ( AFPUserVisibleException $excep ) {
|
||||
$this->mAllowShort = $origAS;
|
||||
|
||||
return array( $excep->getMessage(), $excep->mPosition );
|
||||
return array( $excep->getMessageObj()->text(), $excep->mPosition );
|
||||
}
|
||||
$this->mAllowShort = $origAS;
|
||||
|
||||
|
|
Loading…
Reference in a new issue