diff --git a/includes/Linker.php b/includes/Linker.php
index 0ecd744c9ed..7eda21bce16 100644
--- a/includes/Linker.php
+++ b/includes/Linker.php
@@ -1168,7 +1168,10 @@ class Linker {
$title->getDBkey(), $section );
}
if ( $sectionTitle ) {
- $link = Linker::makeCommentLink( $sectionTitle, $wgLang->getArrow(), $wikiId, 'noclasses' );
+ $link = Linker::makeCommentLink(
+ $sectionTitle, $wgLang->getArrow() . $auto, $wikiId, 'noclasses'
+ );
+ $auto = '';
} else {
$link = '';
}
@@ -1181,10 +1184,11 @@ class Linker {
# autocomment $postsep written summary (/* section */ summary)
$auto .= wfMessage( 'colon-separator' )->inContentLanguage()->escaped();
}
- $auto = '';
- $comment = $pre . $link . $wgLang->getDirMark()
- . '' . $auto;
- $append .= '';
+ if ( $auto ) {
+ $auto = '';
+ $append .= '';
+ }
+ $comment = $pre . $link . $wgLang->getDirMark() . $auto;
}
return $comment;
},
diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt
index 6d5054e6ce4..e034fec58df 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -24422,7 +24422,7 @@ comment title=[[Main Page]]
!! wikitext
/* External links */ removed bogus entries
!! html/php
-→ removed bogus entries
+→External links removed bogus entries
!!end
!! test
@@ -24432,7 +24432,7 @@ comment title=[[Main Page]]
!! wikitext
pre-comment text /* External links */ removed bogus entries
!! html/php
-pre-comment text → removed bogus entries
+pre-comment text →External links removed bogus entries
!!end
!! test
@@ -24442,7 +24442,7 @@ comment local title=[[Main Page]]
!! wikitext
/* External links */ removed bogus entries
!! html/php
-→ removed bogus entries
+→External links removed bogus entries
!!end
!! test
@@ -24553,7 +24553,7 @@ title=[[Main Page]]
!! wikitext
/* __hello__world__ */
!! html/php
-→
+→__hello__world__
!! end
!! test
diff --git a/tests/phpunit/includes/LinkerTest.php b/tests/phpunit/includes/LinkerTest.php
index b8aecc05a52..52a3c914fbc 100644
--- a/tests/phpunit/includes/LinkerTest.php
+++ b/tests/phpunit/includes/LinkerTest.php
@@ -152,43 +152,43 @@ class LinkerTest extends MediaWikiLangTestCase {
],
// Linker::formatAutocomments
[
- '→',
+ '→autocomment',
"/* autocomment */",
],
[
- '→',
+ '→linkie?',
"/* [[linkie?]] */",
],
[
- '→ post',
+ '→autocomment post',
"/* autocomment */ post",
],
[
- 'pre →',
+ 'pre →autocomment',
"pre /* autocomment */",
],
[
- 'pre → post',
+ 'pre →autocomment post',
"pre /* autocomment */ post",
],
[
- '→ multiple? → ',
- "/* autocomment */ multiple? /* autocomment2 */ ",
+ '→autocomment multiple? →autocomment2',
+ "/* autocomment */ multiple? /* autocomment2 */",
],
[
- '→ T70361',
+ '→autocomment containing /* T70361',
"/* autocomment containing /* */ T70361"
],
[
- '→',
+ '→autocomment containing "quotes"',
"/* autocomment containing \"quotes\" */"
],
[
- '→',
+ '→autocomment containing <script>tags</script>',
"/* autocomment containing */"
],
[
- '→',
+ '→autocomment',
"/* autocomment */",
false, true
],
@@ -198,12 +198,12 @@ class LinkerTest extends MediaWikiLangTestCase {
null
],
[
- '→',
+ '→autocomment',
"/* autocomment */",
false, false
],
[
- '→',
+ '→autocomment',
"/* autocomment */",
false, false, $wikiId
],