Page MenuHomePhabricator

appendtext parameter of action=edit API appears to no longer add a newline between original and appended content
Closed, InvalidPublic

Description

On Commons we’ve noticed that several gadgets which are supposed to append a section on a talk page have started to produce wikitext like this:

...26 October 2023 (UTC)== New heading ==
New section content...

These gadgets are using the appendtext parameter of the edit API; it appears that the appended text previously used to be prepended with a line break (or equivalently, that the existing content previously always ended with a line break, Unix style), but that this is now no longer the case, so the “heading” is directly added to the previous signature.

Needs more investigation whether this is really a change in MediaWiki, I guess.

Affected gadgets:

Event Timeline

LucasWerkmeister renamed this task from appendtext parameter of action=edit API appears to no longer append a trailing newline to appendtext parameter of action=edit API appears to no longer add a newline between original and appended content.Oct 28 2023, 6:32 PM

I looked at the edits made using the affected user rights manager gadget:

The first edit with this problem was on the 19.08.2023 (diff)

The last edit which automatically added the content as a new line was on the 16.08.2023 (diff)

The gadget was not changed during this time.

That would suggest the MediaWiki change (if there was one) happened in the 1.42.0-wmf.1 train (T348354). @ssastry do you think this could be related to the parser cache or parsoid changes you mentioned there?

So far, I haven’t been able to get the suspected previous behavior (that a \n was automatically inserted) reproduced on localhost, even when checking out older MediaWiki core commits.

appendtext and prependtext does not add newlines, there are to add directly to the end/begin of the existing text.

The userRightsManager gadget depends on a newline generated by the substituted templates (the appendtext is just {{subst: ... }} ~~~~), the template for the filemover right provides this empty newline at the begin, while the other templates does not, so all the filemover addition looks correct, while other looks broken.

Global replace is broken also in january 2023 - https://commons.wikimedia.org/w/index.php?diff=728886061 / Older https://commons.wikimedia.org/w/index.php?diff=614577825

Another gadget provides newlines since the begin in 2012 - https://commons.wikimedia.org/w/index.php?title=MediaWiki:ProcessFileMoverRequests.js&oldid=68687244

To add new section use action=edit with section=new&sectiontitle=...&text=...

The api parameters are not adding newlines, please check the gadgets using this parameter. Maybe the newlines are indirect added by pst due to templates used to store the wikitext added as new section to the pages.

Using action=edit with section=new gives better edit summary when used to add new sections, compare hint added with abd979818adec33feab128e4c433bd8dbf3344f4