Page MenuHomePhabricator

Prevent Schema edits with no changes
Closed, ResolvedPublic

Description

As an editor, I want to be sure that when I “edit” a Schema, but don’t make any actual changes, then no edit to the page is made.

Problem:
Currently, it’s possible that an edit is made even if there is no difference, because the underlying JSON serialization may change.

Example:
This diff is empty, but in the underlying JSON representation, the aliases changed from having "de": [], "fr": [], "nl": [] in revision 103 not not having those empty lists anymore in revision 104.

BDD
WHEN I go to edit a schema
AND I only add whitespace at the beginning or end of labels, descriptions, aliases, or schema text
THEN no edit is recorded in the page history when I save

Open questions:

  • There are two ways we can tackle this (not necessarily exclusive). Which one(s) do we want to pursue?
    • Try to always generate the same JSON (strip empty aliases arrays, consistent key order, etc.). However, this can still produce empty edits if the serialization version changes.
    • Diff the old and new Schema and don’t save if the difference is empty.

Event Timeline

Intuitively, I would like to see both approaches done:

  1. always generate the same, reproducible JSON without empty language keys
  2. don't save if the diff is empty

What do you think?

Yeah, that makes sense to me. Normalizing the JSON more should also make the byte size of the revisions more useful.

Change 500456 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseSchema@master] Filter empty elements in SchemaEncoder

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

Change 500456 merged by jenkins-bot:
[mediawiki/extensions/WikibaseSchema@master] Filter empty elements in SchemaEncoder

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

Change 500467 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseSchema@master] Sort labels, descriptions, aliases by language code

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

Change 500467 merged by jenkins-bot:
[mediawiki/extensions/WikibaseSchema@master] Sort labels, descriptions, aliases by language code

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

Lucas_Werkmeister_WMDE moved this task from Backlog to Doing on the Shape Expressions Sprint 5 board.

I’ll see if I can do the “diff old/new schema” part.

hoo reassigned this task from hoo to Lucas_Werkmeister_WMDE.
hoo subscribed.

Yay for Phabricator not telling me about the conflicts…

Change 501523 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseSchema@master] WIP: Fully prevent empty edits

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

Change 501601 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseSchema@master] Add more tests for MediaWikiRevisionSchemaUpdater

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

Change 501523 merged by jenkins-bot:
[mediawiki/extensions/WikibaseSchema@master] Fully prevent empty edits

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

Change 501601 merged by jenkins-bot:
[mediawiki/extensions/WikibaseSchema@master] Add more tests for MediaWikiRevisionSchemaUpdater

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