Jump to content

Wikidata/Development/Entity redirect after merge

From Meta, a Wikimedia project coordination wiki
Tracked in Phabricator:
Bug 57745

When a user merges an item at Wikidata using the merge api feature or the special page coming, the old page that got merged should turn into a redirect linking to the target item. This should maybe also be possible with properties.

Use cases

[edit]
Steps of merging
  1. User recognizes that two items are about the same topic and should be merged.
  2. Two item ids are given to the api or the special page (from and to)
  3. After all sitelinks, statements etc. got merged, the from item should be turned into a redirect pointing to the to item.
  4. The history of the from item could either be also merged into the to item's history (this sounds really hard and crazy) or, maybe the better approach, it could stay in the from item. This would make unmerging easier and also makes sense if we can still access a redirect's history.
Steps of visiting a redirect
  1. the user sees the content of the target item
  2. a notice is shown that the user was redirected (as in normal MediaWiki redirects)
Steps of unmerging
  1. when two items need to get unmerged (vandalism, user's mistake, ...) it is currently very hard to undo the merge. First, an admin has to undelete the old item, then the target item has to be reverted and after that the old item
  2. if one entity was a redirect, it should only be one edit to undo a merge that was done via the api (not sure if this is possible)
How to handle statements pointing to a redirect
  1. if a redirecting entity is used as a statement datavalue, it should be handled as if it was the target item (same label etc.)
  2. api modules etc. have to decide whether to give the old or the target entity id as value

Technical notes

[edit]

There are several models how redirects should be handled on the technical side:mainly quoted from Daniel's mail

Description Support Support Oppose Contra

Implement redirects as a "mode" Entities may have.

  • redirects can seamlessly occur anywhere "real" entities can occur, e.g. in dumps, diffs, undo operations, etc
  • many operations that are defined on "real" entities are not defined on redirects (e.g. "set label", etc), so we would end up with a lot if "if redirect, do this, else, do that" checks all over the code base.

Implement redirects as a "mode" any EntityContent may have

  • following the idea that redirects are really a MediaWiki concept, and should be implemented outside the Wikibase data model
  • still requires a lot of "if redirect, do this, else, do that" checks, but only in places dealing with EntityContent, not all places dealing with Entities.

Use a separate entity type for representing redirects: a RedirectContent points to an EntityContent

  • no "mode", no need for extra checks, no chance for confusion
  • breaks a few basic assumptions, most importantly the assumption that all pages in an entity namespace contain an EntityContent of the respective type
  • needs special handling to allow e.g. a diff to be shown between an EntityContent and a RedirectContent.

make redirects a special type of Entity, besides Item and Property; differentiate between Entity and LabeledEntity

  • allows straight forward diffs (and thus undo-operations) between the redirected and the previous, un-redirected version of a page
  • would not compromise code that operates on Item on Property objects
  • need to insert another class into the hierarchy (let's call it LabeledEntity) which would be a base class for Item and Property, but not for Redirect
  • requires quite a bit of refactoring

Perhaps only the options #2 and maybe #4 will be taken in consideration. Option #2 is the one that will be implemented.