Page MenuHomePhabricator

Implement Redirects in ItemContent
Closed, ResolvedPublic


EntityContent should be able to represent redirects (while Entity and the rest of the Wikibase datamodel should not know about redirects).

Version: unspecified
Severity: normal
Whiteboard: u=dev c=backend p=20 s=2014-06-17
See Also:



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:30 AM
bzimport set Reference to bz57744.
bzimport added a subscriber: Unknown Object (MLST).

Change 89810 had a related patch set uploaded by Daniel Kinzler:
Allow ItemContent to represent a redirect.

Should this really be implemented in EntityContent, or might we use the standard redirect feature of MediaWiki?

@Bene: in order to use MediaWiki's standard redirect feature, EntityContent must implement that feature for, well, entities. The Content interface defines the appropriate methods, EntityContent currently doesn't do anything with them though.

However, I'm no longer convinced that this is the best approach to implementing redirects for Wikibase (though the redirect interface in Content must be used in *some* way), see my my mail to wikidata-tech:

As per discussion on the mailing list, redirects are to be implemented as a mode of EntityContent. See for a summary

We have discussed the expected behavior of entity redirects internally. Here are the key points:

  • An Entity object cannot represent a redirect
  • An EntityContent object may represent a redirect. In that case, calling getEntity() will fail.
  • Redirects should only be possible within one kind of entity, redirects from one kind of entity to another are not supported.
  • For now, only Items can redirect to other Items. Redirects for Properties will not be supported initially, if ever.
  • The only way to create a redirect should be by merging two entities. Ideally, the merge would involve two edits to the redirected item: one to "empty" it, and a separate one to turn it into a redirect. This allows for better diffs, for easier undo/revert, and a clearer edit history.
  • Redirects can be turned back into normal entities by undoing/reverting the edit that turned them into a redirect (if that is possible without conflicts).
  • On the RDF level, redirects a re modeled as an owl:sameAs relationship between concept URIs. This also means that the redirected document URL is considered to be "about" the target's concept URI.
  • Viewing a page of an entity that is a redirect shall show the content of the redirect target, as usual. This can be disabled withing the redirect=no parameter, as usual.
  • When viewing an entity page that references redirected entity IDs, it would be nice to mark these somehow. We will probably not support this initially.
  • When accessing an entity explicitly via ID from a client wiki, any redirects should be automatically resolved.
  • When trying to edit an entity that is a redirect (via the API od a special page), the edit will fail.
  • When fetching entities via the API, redirects should NOT be automatically resolved, unless this is requested using redirects=resolve.
  • When requesting entity data using a canonical data URL or concept URI, redirects should be resolved automatically. The resulting data does not need to indicate that a redirect was resolved.
  • For RDF data, the relevant owl:sameAs triples should be included, no matter whether what URL the document was accessed with.
  • All redirects should be present in the full RDF dump, as owl:sameAs triples.
  • Redirects are not present in JSON dumps of entities, but there would be a separate JSON dump for redirects.
  • Redirects from wikitext pages to entities will work as usual, and do not concern us.
  • We should make sure the "redirected from" line is shown correctly in entity pages.
  • Revert/Restore needs to work as expected
  • Diffs between the redirect and non-redirect versions of an entity need to work
  • EntityRevisionLookup will not resolve redirects and will fail when used with a redirected entity ID. This could be relaxed if no specific revision is requested.
  • EntityLookup will resolve redirects if explicitly asked to do so.
  • The EntityPerPage table will maintain the link between a redirected entity ID and the wiki page that contains the redirect. We will add a column (or an extra table) that holds the redirect targets.

Change 134379 merged by jenkins-bot:
Implement redirects in ItemContent