From 4dbde4dcf0a0f6dc378a21a0ed42829a29157861 Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Sat, 6 Feb 2021 15:36:41 +0100 Subject: [PATCH] Use a different message prefix for parser warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The abusefilter-warning prefix is reserved for filter warnings. Pointed out by Matěj. Change-Id: I169e4c3d29b08c7f5af2136a683fc4427f8e93f5 --- i18n/en.json | 2 +- i18n/qqq.json | 2 +- includes/Parser/UserVisibleWarning.php | 4 ++-- tests/phpunit/integration/Api/CheckSyntaxTest.php | 4 ++-- tests/phpunit/unit/Parser/UserVisibleWarningTest.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/i18n/en.json b/i18n/en.json index 89b6171ef..b4056d018 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -466,7 +466,7 @@ "abusefilter-exception-invalidiprange": "Invalid IP range \"$2\" provided at character $1.", "abusefilter-exception-disabledvar": "Variable $2 at character $1 is no longer in use.", "abusefilter-exception-variablevariable": "set and set_var expect the first argument to be a string literal, found at character $1.", - "abusefilter-warning-match-empty-regex": "This regular expression matches the empty string, at character $1", + "abusefilter-parser-warning-match-empty-regex": "This regular expression matches the empty string, at character $1", "abusefilter-action-tag": "Tag", "abusefilter-action-throttle": "Throttle", "abusefilter-action-warn": "Warn", diff --git a/i18n/qqq.json b/i18n/qqq.json index 108a41998..14f4b11c8 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -506,7 +506,7 @@ "abusefilter-exception-invalidiprange": "Error message from the abuse filter parser. Parameters:\n* $1 - Position in the string\n* $2 - String provided as an argument to a function", "abusefilter-exception-disabledvar": "Error message from the abuse filter parser. Parameters:\n* $1 - Position in the string\n* $2 - Name of the disabled variable", "abusefilter-exception-variablevariable": "{{doc-important|Do not translate \"'''set'''\" and \"'''set_var'''\".}} Error message from the abuse filter parser. Parameters:\n* $1 - Position in the string", - "abusefilter-warning-match-empty-regex": "Warning message from the abuse filter parser. Parameters:\n* $1 - Position in the string", + "abusefilter-parser-warning-match-empty-regex": "Warning message from the abuse filter parser. Parameters:\n* $1 - Position in the string", "abusefilter-action-tag": "{{doc-abusefilter-action}}\n\nThe edit or change can be 'tagged' with a particular tag, which will be shown on Recent Changes, contributions, logs, new pages, history, and everywhere else. \n\nThis is a verb in the imperative form.\n\n{{Identical|Tag}}", "abusefilter-action-throttle": "{{doc-abusefilter-action}}", "abusefilter-action-warn": "{{doc-abusefilter-action}}", diff --git a/includes/Parser/UserVisibleWarning.php b/includes/Parser/UserVisibleWarning.php index 24e01f513..0539653bf 100644 --- a/includes/Parser/UserVisibleWarning.php +++ b/includes/Parser/UserVisibleWarning.php @@ -13,9 +13,9 @@ class UserVisibleWarning extends AFPUserVisibleException { */ public function getMessageObj() : Message { // Give grep a chance to find the usages: - // abusefilter-warning-match-empty-regex + // abusefilter-parser-warning-match-empty-regex return new Message( - 'abusefilter-warning-' . $this->mExceptionID, + 'abusefilter-parser-warning-' . $this->mExceptionID, array_merge( [ $this->mPosition ], $this->mParams ) ); } diff --git a/tests/phpunit/integration/Api/CheckSyntaxTest.php b/tests/phpunit/integration/Api/CheckSyntaxTest.php index f40a18db9..53418cebd 100644 --- a/tests/phpunit/integration/Api/CheckSyntaxTest.php +++ b/tests/phpunit/integration/Api/CheckSyntaxTest.php @@ -81,14 +81,14 @@ class CheckSyntaxTest extends ApiTestCase { 'warnings' => [ [ 'message' => wfMessage( - 'abusefilter-warning-exception-1', + 'abusefilter-parser-warning-exception-1', 3 )->text(), 'character' => 3, ], [ 'message' => wfMessage( - 'abusefilter-warning-exception-2', + 'abusefilter-parser-warning-exception-2', 8, 'param' )->text(), diff --git a/tests/phpunit/unit/Parser/UserVisibleWarningTest.php b/tests/phpunit/unit/Parser/UserVisibleWarningTest.php index 67368aded..3ba173645 100644 --- a/tests/phpunit/unit/Parser/UserVisibleWarningTest.php +++ b/tests/phpunit/unit/Parser/UserVisibleWarningTest.php @@ -22,7 +22,7 @@ class UserVisibleWarningTest extends MediaWikiUnitTestCase { $position = 42; $params = [ 'foo' ]; $message = ( new UserVisibleWarning( $excID, $position, $params ) )->getMessageObj(); - $this->assertSame( 'abusefilter-warning-' . $excID, $message->getKey(), 'msg key' ); + $this->assertSame( 'abusefilter-parser-warning-' . $excID, $message->getKey(), 'msg key' ); $this->assertArrayEquals( array_merge( [ $position ], $params ), $message->getParams(), 'msg params' ); } }