mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 14:36:51 +00:00
Drop unused cite_reference(s)_link_prefix messages
Same as Icfa8215 where we removed the …_suffix messages. This patch is not blocked on anything according to CodeSearch: https://codesearch.wmcloud.org/search/?q=cite_references%3F_link_prefix According to GlobalSearch there are 2 usages we need to talk about: https://global-search.toolforge.org/?q=.®ex=1&namespaces=8&title=Cite.references%3F.link.prefix.* zh.wiktionary replaces "cite_ref-" with "_ref-", and "cite_note-" with "_note-", i.e. they did nothing but remove the word "cite". This happened in 2006, with no explanation. ka.wikibooks and ka.wikiquote replace "cite_note-" with "_შენიშვნა-", which translates back to "_note-". One user did this in 2007, 16 seconds apart. It appears like both are attempts to localize what can be localized, no matter if it's really necessary or not. https://zh.wiktionary.org/wiki/Special:Contributions/Shibo77?offset=20060510 https://ka.wikiquote.org/wiki/Special:Contributions/Trulala?offset=20070219 Note how one user experimented with an "a" in some of the edits to see what effect the change might have, to imediatelly revert it. The modifications don't really have an effect on anything, except on the anchors in the resulting <a href="#_ref-5"> and <sup id="_ref-5"> HTML. It might also be briefly visible in the browser's address bar when such a link is clicked. We can only assume the two users did this to make the URL appear shorter (?). A discussion apparently never happened. Bot users are inactive. Both pieces of HTML are generated in the Cite code. Removing the messages will change all places the same time. All links will continue to work. The only possible effect is that hard-coded weblinks to an individual reference will link to the top of the article instead. But: a) This is extremely unlikely to happen. There is no reason to link to a reference from outside of the article. b) Such links are not guaranteed to work anyway as they can break for a multitude of other reasons, e.g. the <ref> being renamed, removed, or replaced. c) Even if such a link breaks, it still links to the correct article. There is also no on-wiki code on zh.wiktionary that would do anything with the shortened prefix: https://zh.wiktionary.org/w/index.php?search=insource%3A%2F_%28ref%7Cnote%29-%2F&title=Special%3A%E6%90%9C%E7%B4%A2&profile=advanced&fulltext=1&ns2=1&ns4=1&ns8=1&ns10=1&ns12=1&ns828=1&ns2300=1 I argue this is safe to remove, even without contacting the mentioned communities first. Bug: T321217 Change-Id: I160a119710dc35679dbdc2f39ddf453dbd5a5dfa
This commit is contained in:
parent
be755491cc
commit
ddda536792
|
@ -213,7 +213,6 @@
|
|||
"ext.cite.highlighting.css"
|
||||
],
|
||||
"messages": [
|
||||
"cite_reference_link_prefix",
|
||||
"cite_references_link_accessibility_label",
|
||||
"cite_references_link_many_accessibility_label",
|
||||
"cite_references_link_accessibility_back_label"
|
||||
|
|
|
@ -40,8 +40,6 @@
|
|||
"cite_error_empty_references_define": "<code><ref></code> tag with name \"$1\" defined in <code><references></code> 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_prefix": "cite_ref-",
|
||||
"cite_references_link_prefix": "cite_note-",
|
||||
"cite_reference_backlink_symbol": "↑",
|
||||
"cite_reference_link": "<sup id=\"$1\" class=\"reference\">[[#$2|[$3]]]</sup>",
|
||||
"cite_references_link_one": "<li id=\"$1\"$4><span class=\"mw-cite-backlink\">[[#$2|↑]]</span> $3</li>",
|
||||
|
|
|
@ -44,8 +44,6 @@
|
|||
"cite_error_empty_references_define": "Error message shown when there is a <code><ref></code> inside <code><references></code>, but it does not have any content, e.g.\n<pre>\n<references>\n<ref name=\"foo\" />\n</references>\n</pre>\nParameters:\n* $1 - the <code><nowiki>name</nowiki></code> of the erroneous <code><ref></code> (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_prefix": "{{notranslate}}",
|
||||
"cite_references_link_prefix": "{{notranslate}}",
|
||||
"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",
|
||||
|
|
|
@ -11,10 +11,8 @@
|
|||
* @return {boolean}
|
||||
*/
|
||||
function isNamedReference( id ) {
|
||||
const prefix = mw.msg( 'cite_reference_link_prefix' );
|
||||
|
||||
// Note: This assumes IDs start with the prefix; this is guaranteed by the parser function
|
||||
return /\D/.test( id.slice( prefix.length ) );
|
||||
return /^cite_ref-\D/.test( id );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,12 +12,6 @@ use MediaWiki\Parser\Sanitizer;
|
|||
*/
|
||||
class AnchorFormatter {
|
||||
|
||||
private ReferenceMessageLocalizer $messageLocalizer;
|
||||
|
||||
public function __construct( ReferenceMessageLocalizer $messageLocalizer ) {
|
||||
$this->messageLocalizer = $messageLocalizer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an id for use in wikitext output based on a key and
|
||||
* optionally the number of it, used in <references>, not <ref>
|
||||
|
@ -29,11 +23,10 @@ class AnchorFormatter {
|
|||
* @return string
|
||||
*/
|
||||
private function refKey( $key, ?string $num ): string {
|
||||
$prefix = $this->messageLocalizer->msg( 'cite_reference_link_prefix' )->plain();
|
||||
if ( $num !== null ) {
|
||||
$key = $key . '_' . $num;
|
||||
}
|
||||
return $this->normalizeKey( $prefix . $key );
|
||||
return $this->normalizeKey( "cite_ref-$key" );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,8 +61,7 @@ class AnchorFormatter {
|
|||
* @return string
|
||||
*/
|
||||
private function getReferencesKey( string $key ): string {
|
||||
$prefix = $this->messageLocalizer->msg( 'cite_references_link_prefix' )->plain();
|
||||
return $this->normalizeKey( $prefix . $key );
|
||||
return $this->normalizeKey( "cite_note-$key" );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -78,7 +78,7 @@ class Cite {
|
|||
$messageLocalizer = new ReferenceMessageLocalizer( $parser->getContentLanguage() );
|
||||
$this->errorReporter = new ErrorReporter( $messageLocalizer );
|
||||
$this->referenceStack = new ReferenceStack();
|
||||
$anchorFormatter = new AnchorFormatter( $messageLocalizer );
|
||||
$anchorFormatter = new AnchorFormatter();
|
||||
$this->footnoteMarkFormatter = new FootnoteMarkFormatter(
|
||||
$this->errorReporter,
|
||||
$anchorFormatter,
|
||||
|
|
|
@ -14,8 +14,8 @@ class ReferenceMessageLocalizerTest extends \MediaWikiIntegrationTestCase {
|
|||
public function testMsg() {
|
||||
$localizer = new ReferenceMessageLocalizer( new LanguageQqx() );
|
||||
$this->assertSame(
|
||||
'(cite_reference_link_prefix)',
|
||||
$localizer->msg( 'cite_reference_link_prefix' )->plain() );
|
||||
'(cite-desc)',
|
||||
$localizer->msg( 'cite-desc' )->plain() );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
namespace Cite\Tests\Integration;
|
||||
|
||||
use Cite\AnchorFormatter;
|
||||
use Cite\ReferenceMessageLocalizer;
|
||||
use MediaWiki\Parser\Sanitizer;
|
||||
use Message;
|
||||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
/**
|
||||
|
@ -20,37 +18,21 @@ class AnchorFormatterTest extends \MediaWikiIntegrationTestCase {
|
|||
}
|
||||
|
||||
public function testRefKey() {
|
||||
$mockMessageLocalizer = $this->createMock( ReferenceMessageLocalizer::class );
|
||||
$mockMessageLocalizer->method( 'msg' )->willReturnCallback(
|
||||
function ( ...$args ) {
|
||||
$msg = $this->createMock( Message::class );
|
||||
$msg->method( 'plain' )->willReturn( '(' . implode( '|', $args ) . ')' );
|
||||
return $msg;
|
||||
}
|
||||
);
|
||||
$formatter = new AnchorFormatter( $mockMessageLocalizer );
|
||||
$formatter = new AnchorFormatter();
|
||||
|
||||
$this->assertSame(
|
||||
'(cite_reference_link_prefix)key',
|
||||
'cite_ref-key',
|
||||
$formatter->backLink( 'key', null ) );
|
||||
$this->assertSame(
|
||||
'(cite_reference_link_prefix)key_2',
|
||||
'cite_ref-key_2',
|
||||
$formatter->backLink( 'key', '2' ) );
|
||||
}
|
||||
|
||||
public function testGetReferencesKey() {
|
||||
$mockMessageLocalizer = $this->createMock( ReferenceMessageLocalizer::class );
|
||||
$mockMessageLocalizer->method( 'msg' )->willReturnCallback(
|
||||
function ( ...$args ) {
|
||||
$msg = $this->createMock( Message::class );
|
||||
$msg->method( 'plain' )->willReturn( '(' . implode( '|', $args ) . ')' );
|
||||
return $msg;
|
||||
}
|
||||
);
|
||||
$formatter = new AnchorFormatter( $mockMessageLocalizer );
|
||||
$formatter = new AnchorFormatter();
|
||||
|
||||
$this->assertSame(
|
||||
'(cite_references_link_prefix)key',
|
||||
'cite_note-key',
|
||||
$formatter->jumpLink( 'key' ) );
|
||||
}
|
||||
|
||||
|
@ -59,8 +41,7 @@ class AnchorFormatterTest extends \MediaWikiIntegrationTestCase {
|
|||
*/
|
||||
public function testNormalizeKey( $key, $expected ) {
|
||||
/** @var AnchorFormatter $formatter */
|
||||
$formatter = TestingAccessWrapper::newFromObject( new AnchorFormatter(
|
||||
$this->createMock( ReferenceMessageLocalizer::class ) ) );
|
||||
$formatter = TestingAccessWrapper::newFromObject( new AnchorFormatter() );
|
||||
$normalized = $formatter->normalizeKey( $key );
|
||||
$encoded = Sanitizer::safeEncodeAttribute( Sanitizer::escapeIdForLink( $normalized ) );
|
||||
$this->assertSame( $expected, $encoded );
|
||||
|
|
Loading…
Reference in a new issue