Page MenuHomePhabricator

Displaying mapframes for geocoordinate on client requires preprocessing by the user
Closed, ResolvedPublic8 Story Points

Description

As pointed out by @Tpt in T210926#4999461:

If Wikibase Client tries to format a coordinate via entity:formatStatements() in Lua, the editor will need to manually preprocess the result of these expressions. That is unacceptable, as it breaks the current way these constructs are used, it is undocumented and also very inconvenient to use. The {{#statements:…}} parser function seems to be unaffected by this.

As a solution, we should make sure we Parser::preprocess all (or just if <maplink> is in there?) wikitext generated in StatementTransclusionInteractor::formatSnaks. For this to work, we will need to pass the current Parser instance through to that function :/

As (AFAIR) re-preprocessing already pre-processed wikitext is a noop, we can safely do this change.

Steps to reproduce

  1. Set up the Kartographer extension on your client wiki and confirm it is working.
  2. Enable the useKartographerMaplinkInWikitext Wikibase Client settings.
  3. Add a globe coordinate value to an item (needs to be an earth coordinate)
  4. Access that information on a client wiki page via the following Lua snippet: mw.wikibase.getEntity( 'yourEntityId' ):formatStatements( 'yourGlobeCoordPropertyId' ).value

Right now this is going to show you <maplink …> on the page, while it should output an interactive map showing the coordinate.

Event Timeline

hoo created this task.Apr 4 2019, 3:51 PM
Restricted Application added subscribers: Liuxinyu970226, Aklapper. · View Herald TranscriptApr 4 2019, 3:51 PM
Lydia_Pintscher triaged this task as Normal priority.Apr 9 2019, 8:28 AM
Lydia_Pintscher moved this task from Incoming to Ready to estimate on the Wikidata-Campsite board.
WMDE-leszek updated the task description. (Show Details)Apr 10 2019, 1:43 PM

Add steps to reproduce

hoo updated the task description. (Show Details)Apr 10 2019, 1:54 PM
hoo removed the point value for this task.
hoo set the point value for this task to 8.

I can’t manage to reproduce this – both on my local wiki and on Wikidata, the {{#statements}} snippet gives me a working maplink, not a broken mapframe.

hoo updated the task description. (Show Details)Apr 10 2019, 6:05 PM
hoo added a comment.Apr 10 2019, 6:16 PM
This comment was removed by hoo.
hoo updated the task description. (Show Details)Apr 10 2019, 6:27 PM
hoo updated the task description. (Show Details)Apr 10 2019, 6:34 PM
hoo added a comment.Apr 10 2019, 6:39 PM

Seems I had this quiet wrong initially… no idea what I tested then. Anyway this is only affecting Lua, not the parser function and we don't ever output <mapframes> (just <maplink>). We might still want to fix this in the way laid out in the description, but we could also use frame:preprocess as provided by Scribunto in the relevant Lua functions (entity:formatStatements, mw.wikibase.formatValue, and mw.wikibase.formatValues) .

hoo claimed this task.Apr 11 2019, 10:28 AM

Change 503375 had a related patch set uploaded (by Hoo man; owner: Hoo man):
[mediawiki/extensions/Wikibase@master] Allow using Kartographer maps via Lua without preprocessing

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

I set up a beta test on https://wikidata.beta.wmflabs.org/wiki/Talk:Q15905 – after the fix is deployed, purging that page should show a working maplink. (I’ve archived the current output for comparison.)

Change 503375 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Allow using Kartographer maps via Lua without preprocessing

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