Page MenuHomePhabricator

Section-level images: Check for dirty diffs
Closed, DuplicatePublic


We have seen some dirty diffs in section image tasks (where Parsoid transforms the wikitext of an article to HTML for display in VisualEditor, VE sends it back without any changes to be saved, Parsoid transforms it back to wikitext, and despite no intentional changes, the wikitext ends up slightly different). These could cause two kinds of problems:

  • On accepted recommendations, the wikitext gets changed in arbitrary ways besides the image being added. This is not a big deal but makes the edit more confusing and harder to review for patrollers.
  • On rejected recommendations, the VE plugin is supposed to make a null edit, but a dirty diff will turn it into a real edit, and a very confusing one at that (the edit summary will say "one image added" but actually the edit will be something completely unrelated).

We have seen this happening alongside T340170: Section-level images: Placeholder gets saved in wikitext on rejection, and also in local dev environments with the placeholder bug fixed. Neither is 100% indicative that the problem still exists (the VE/Parsoid selective serialization logic that's used to avoid dirty diffs is complicated and not easily set up locally; and the presence of the placeholder might have triggered wikitext changes by e.g. inserting a block element inside a line) but we should be on the lookout.

We can find dirty rejections by looking for edits which are tagged with the section image tag, but do not have an associated log entry (since we don't associate a revision with rejection log entries). For dirty accepts, we'd probably have to get the diffs from the MediaWiki API and check them with a regex.

Event Timeline

@kostajh pointed out that this is an instance of a problem we have with other structured tasks as well, so I don't think it's worth putting effort into checking - we already know it's happening, and we already know it isn't happening too often.

Filed T340532: Structured tasks should never make an edit when the user rejects the recommendation and T340530: Image recommendation structured tasks should use an appropriate edit summary on rejection about the more general problem.