From 202c0d3636d00c891ba8b418cdb336ee7ce89170 Mon Sep 17 00:00:00 2001 From: thiemowmde Date: Mon, 27 Nov 2023 18:34:55 +0100 Subject: [PATCH] =?UTF-8?q?Drop=20unused=20=E2=80=A6=5Fsuffix=20and=20?= =?UTF-8?q?=E2=80=A6=5Fkey=5Fwith=5Fnum=20messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The three messages cite_reference_link_key_with_num, cite_reference_link_suffix, and cite_references_link_suffix are not used for anything. According to CodeSearch: https://codesearch.wmcloud.org/search/?i=1&q=cite_references?_link_(key|suffix) According to GlobalSearch: https://global-search.toolforge.org/?q=.®ex=1&namespaces=8&title=Cite.references?.link.(key|suffix).* For comparison: https://global-search.toolforge.org/?q=.®ex=1&namespaces=8&title=Cite.references?.link.prefix.* They are not meant to be localized, as noted in qqq.json. As many messages in Cite the idea is that individual wikis can customize the generated HTML (!) via such messages. These particular ones apparently have been introduced just because it's technically possible, but never been used for anything. They exist since the very first commit from 2005: https://phabricator.wikimedia.org/rECITb714bf09 Note how these messages aren't even visible anywhere, except in the browser's address bar as part of a #… fragment. This obviously doesn't solve T321217 but helps minimizing the surface. Bug: T321217 Change-Id: Icfa82155e3b02df39bb6e924bc472f6edc565d5f --- i18n/en.json | 3 --- i18n/qqq.json | 3 --- modules/ext.cite.highlighting.js | 3 +-- src/AnchorFormatter.php | 11 +++-------- tests/phpunit/integration/AnchorFormatterTest.php | 7 +++---- 5 files changed, 7 insertions(+), 20 deletions(-) diff --git a/i18n/en.json b/i18n/en.json index dd5343922..56f4587cc 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -38,11 +38,8 @@ "cite_error_empty_references_define": "<ref> tag with name \"$1\" defined in <references> group \"$2\" has no content.", "cite-tracking-category-cite-error": "Pages with reference errors", "cite-tracking-category-cite-error-desc": "Pages in this category have errors in the usage of references tags.", - "cite_reference_link_key_with_num": "$1_$2", "cite_reference_link_prefix": "cite_ref-", - "cite_reference_link_suffix": "", "cite_references_link_prefix": "cite_note-", - "cite_references_link_suffix": "", "cite_reference_backlink_symbol": "↑", "cite_reference_link": "[[#$2|[$3]]]", "cite_references_link_one": "
  • [[#$2|↑]] $3
  • ", diff --git a/i18n/qqq.json b/i18n/qqq.json index 14e1783ff..8228efc08 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -42,11 +42,8 @@ "cite_error_empty_references_define": "Error message shown when there is a <ref> inside <references>, but it does not have any content, e.g.\n
    \n\n\n\n
    \nParameters:\n* $1 - the name of the erroneous <ref> (in the above example, “foo”)", "cite-tracking-category-cite-error": "{{tracking category name}}\nTracking category name.", "cite-tracking-category-cite-error-desc": "Tracking category description.", - "cite_reference_link_key_with_num": "{{notranslate}}\n\nParameters:\n* $1 - the key\n* $2 - the number of the key", "cite_reference_link_prefix": "{{notranslate}}", - "cite_reference_link_suffix": "{{notranslate}}", "cite_references_link_prefix": "{{notranslate}}", - "cite_references_link_suffix": "{{ignored}}", "cite_reference_backlink_symbol": "{{optional}}\nSymbol used for the reference section, used to link back to where the reference is used.", "cite_reference_link": "{{notranslate}}\n\nParameters:\n* $1 - ref key\n* $2 - references key\n* $3 - link label", "cite_references_link_one": "{{notranslate}}\n\nParameters:\n* $1 - references key\n* $2 - ref key\n* $3 - reference text\n* $4 - optional CSS class for direction", diff --git a/modules/ext.cite.highlighting.js b/modules/ext.cite.highlighting.js index affaf1d01..82e75daa6 100644 --- a/modules/ext.cite.highlighting.js +++ b/modules/ext.cite.highlighting.js @@ -5,8 +5,7 @@ */ ( function () { /** - * Checks if the ID uses a composite format that does not only consist of a sequential number, - * as specified in "cite_reference_link_key_with_num". + * Checks if the ID uses a composite format that does not only consist of a sequential number. * * @param {string} id * @return {boolean} diff --git a/src/AnchorFormatter.php b/src/AnchorFormatter.php index 23604a39c..ad7583244 100644 --- a/src/AnchorFormatter.php +++ b/src/AnchorFormatter.php @@ -27,13 +27,10 @@ class AnchorFormatter { */ private function refKey( string $key, ?string $num ): string { $prefix = $this->messageLocalizer->msg( 'cite_reference_link_prefix' )->plain(); - $suffix = $this->messageLocalizer->msg( 'cite_reference_link_suffix' )->plain(); if ( $num !== null ) { - $key = $this->messageLocalizer->msg( 'cite_reference_link_key_with_num', $key, $num ) - ->plain(); + $key .= '_' . $num; } - - return $this->normalizeKey( $prefix . $key . $suffix ); + return $this->normalizeKey( $prefix . $key ); } /** @@ -71,9 +68,7 @@ class AnchorFormatter { */ private function getReferencesKey( string $key ): string { $prefix = $this->messageLocalizer->msg( 'cite_references_link_prefix' )->plain(); - $suffix = $this->messageLocalizer->msg( 'cite_references_link_suffix' )->plain(); - - return $this->normalizeKey( $prefix . $key . $suffix ); + return $this->normalizeKey( $prefix . $key ); } /** diff --git a/tests/phpunit/integration/AnchorFormatterTest.php b/tests/phpunit/integration/AnchorFormatterTest.php index b0726bfdb..64c30b715 100644 --- a/tests/phpunit/integration/AnchorFormatterTest.php +++ b/tests/phpunit/integration/AnchorFormatterTest.php @@ -38,11 +38,10 @@ class AnchorFormatterTest extends \MediaWikiIntegrationTestCase { $formatter = new AnchorFormatter( $mockMessageLocalizer ); $this->assertSame( - '(cite_reference_link_prefix)key(cite_reference_link_suffix)', + '(cite_reference_link_prefix)key', $formatter->backLink( 'key', null ) ); $this->assertSame( - '(cite_reference_link_prefix)' . - '(cite_reference_link_key_with_num|key|2)(cite_reference_link_suffix)', + '(cite_reference_link_prefix)key_2', $formatter->backLink( 'key', '2' ) ); } @@ -62,7 +61,7 @@ class AnchorFormatterTest extends \MediaWikiIntegrationTestCase { $formatter = new AnchorFormatter( $mockMessageLocalizer ); $this->assertSame( - '(cite_references_link_prefix)key(cite_references_link_suffix)', + '(cite_references_link_prefix)key', $formatter->jumpLink( 'key' ) ); }