Page MenuHomePhabricator

Special:PageMigration inserts comma instead of new line
Closed, ResolvedPublic

Description

Special:PageMigration may import

== header ==,{{template}}
text

instead of

== header ==
{{template}}
text

Note the first new line character has been replaced with a comma. I am not sure about the minimal test case, but this seems related to headings (this seems to doesn’t happen when heading is followed by two successive new lines).

You can try on Meta with Complete list of Wikimedia projects/sv page.

I am pretty sure this is a recent regression.

Event Timeline

Problem is in splitHeaders (rETRA resources/js/ext.translate.special.pagemigration.js:256), introduced in https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Translate/+/608063/1/resources/js/ext.translate.special.pagemigration.js#b263. The callback function replaces the array element (a string) with an array of two strings. jQuery.map() would automatically flatten the array of arrays that was created into a single array of strings, but Array.prototype.map() does not. When the HTML was output, the array of two strings was silently converted to string form. Simply swapping it out for Array.prototype.flatMap() fixes this issue.

Not actually related to T285968, they just happened to look similar (unexplained merging) and occurred together (around headings) often.

Change 718937 had a related patch set uploaded (by AntiCompositeNumber; author: AntiCompositeNumber):

[mediawiki/extensions/Translate@master] ext.translate.special.pagemigration: Replace Array.map() with Array.flatMap()

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

Change 718937 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] ext.translate.special.pagemigration: Flatten Array.map()

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