[[https://hu.wikipedia.org/w/index.php?title=Wikipédia-vita:Válaszeszköz&diff=22924986|This edit]] by @Samat really messed up the page,This task is for two separate wikitext corruption issues that occurred when adding comments to pages using DiscussionTools. They were both triggered by the deployment of the replying API (T252558), but had different causes and solutions. touching even other sections.We should have made two tasks, It should obviously not do this.but it wasn't initially clear that they are unrelated, (Note that it changed `User` and `User vita` namespaces in links to their primary versions `Szerkesztő` and `Szerkesztővita` everywhereand now all of the comments are on this task, //except for// the newly placed signature. This probably means that this mess happened before the pre-save transform.)so let's keep it as is.
=== Issue 1
=== Observed cases of disruption
**Namespaces being changed**(occurred on: 6-7 August; affected edits: ~50-100, see T260393#6384098)
When the replying API was serializing the modified document to HTML, it encoded various characters as HTML entities rather than plain text, resulting in Parsoid's selser not recognizing unmodified parts of the page, causing dirty diffs.
Most of the changes did not damage the page, and only caused distracting diffs, e.g. namespaces in internal links being changed to the canonical ones, external links and internal link anchors being percent-encoded, spaces at the ends of lines being removed.
**Characters being percent encoded**
However, some of them exposed bugs in Parsoid that generate incorrect wikitext, in particular unnecessarily generating a `|link=` parameter (or a localised version) for images (T108504). Also, percent-encoded links are quite annoying in non-Latin-alphabet languages.
- https://w.wiki/ZFo* https://ar.wikipedia.org/w/index.php?title=نقاش_المستخدمة:شيماء&curid=7331385&diff=49547774&oldid=49546611&diffmode=source
**Fixed in: <https://gerrit.wikimedia.org/r/619018>**
=== Issue 2
(occurred on: 12-13 August; affected edits: 2)
**Namespaces and characters being changed**When Parsoid was transforming a HTML document to wikitext, if there was very high replication deplay ("replag"), and if a specific page revision was requested rather than "latest", Parsoid's selser would fetch the wikitext for unmodified parts of the page from the wrong revision, causing page corruption.
At the time some database replica servers were delayed by several hours due to maintenance.
DiscussionTools replying API loads the latest revision of the page using a database query, then asks Parsoid for that revision. In contrast, VisualEditor asks Parsoid for "latest" revision and then checks what revision it received, so it was never affected by this issue. (It's like this because the former was simpler to implement in server-side code and the latter was simpler in client-side code.)
Only two edits were affected:
- https://w.wiki/ZFp* https://hu.wikipedia.org/w/index.php?oldid=22943756&diff=prev&diffmode=source
**Fixed in: <https://gerrit.wikimedia.org/r/621621>**
=== Testing instructions
//At the Arabic, Catalan, Chinese, Czech, Dutch, Korean, Serbian and Swedish beta clusters [i], do the following://
1. Write //and// publish a comment in said wiki's native language using the Reply Tool's `visual` mode
2. Write //and// publish a comment in said wiki's native language using the Reply Tool's `source` mode
3. Ensure that "Step 1" and "Step 2" above did not cause dirty diffs (read: no additional changes are made to the page beyond the text that was written with the Reply Tool being added)
-- //⚠️Please pay special attention to the issues described in the "Observed cases of disruption" section above.//