Page MenuHomePhabricator

in javascript wb.entity does not contain any aliases
Closed, DeclinedPublic

Description

Go to http://wikidata.beta.wmflabs.org/wiki/Q18361, inspect with firebug the wb.entity object, or try to call wb.entity.getAllAliases(). You won't get any aliases, even if there are some added in your language.


Version: unspecified
Severity: normal
Whiteboard: u=dev c=frontend p=0

Details

Reference
bz62442

Event Timeline

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

Teh backend does provide the aliases correctly in the wbEntities variable, try mw.config.get('wbEntity'). Must be a problem with how the UI code processes that.

When was there a wb.entity object? Anyway, since we decoupled the concepts of entityview and page, it is not recommended to access global JS objects anymore. An entity object may be retrieved via an entityview, e.g.:
var entiyview = $( ':wikibase-entityview' ).data( 'entityview' ),

entity = entityview.option( 'value' ); // *
aliases = entity.getAllAliases(); // **
  • Returns the entity object the entityview has been initialized with. In the future, there will be a entityview.value() function which returns the current entity (considering all changes applied to fingerprint, statements, sitelinks without reinitializing the entityview).

I removed wb.entity in 1beb1c8fa873fa4c549c703859ee1dc459b92bf7 as part of the effort to remove global state and coupling of page / wb context to a single entity. This should not have affected anything back in march, though.