Anomie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/297903

Change subject: AFPUserVisibleException should log in English, not the user's 
language
......................................................................

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
---
M AbuseFilter.parser.php
1 file changed, 19 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AbuseFilter 
refs/changes/03/297903/1

diff --git a/AbuseFilter.parser.php b/AbuseFilter.parser.php
index f5c4f1f..110c9b6 100644
--- a/AbuseFilter.parser.php
+++ b/AbuseFilter.parser.php
@@ -536,12 +536,26 @@
 // 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 @@
                // 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 @@
                } catch ( AFPUserVisibleException $excep ) {
                        $this->mAllowShort = $origAS;
 
-                       return array( $excep->getMessage(), $excep->mPosition );
+                       return array( $excep->getMessageObj()->text(), 
$excep->mPosition );
                }
                $this->mAllowShort = $origAS;
 

-- 
To view, visit https://gerrit.wikimedia.org/r/297903
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic17f56aecbe575ef15c6970c4298f889249e1904
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AbuseFilter
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to