Page MenuHomePhabricator

Kartographer's Wikivoyage mode relies on global state (which isn't allowed), so listing numbers are all "1" at all Wikivoyages in VE mode and other issues
Closed, ResolvedPublic0 Estimated Story Points

Description

These numbers should not all be the same:

Screen Shot 2016-07-07 at 3.58.25 PM.png (295×386 px, 57 KB)

Each number on the page should be different, so that the correct entry can be found in the map. (The numbers are created by adding longitude and latitude to any listing template, e.g., {{see}}.)

This screenshot is take from https://en.wikivoyage.org/wiki/Halifax#Parks

Event Timeline

This is the problem with using so many templates. Seems more like a Parsoid issue though.

This looks like the maplink extension maintaining page global state.

Parsoid does not support page global state for extensions and so there is no easy fix here at this point. The reason this does not work for Parsoid is because Parsoid calls the PHP parse API to generate output for extensions, and those expansions might be done individually, in batches, out of order, etc. So, there is no notion of global state that Parsoid has access to.

The long-term plan is to migrate extensions to move away from page global state. So, if we can figure out a way to do the numbering without page global state, that would be one way to do it.

Alternatively, there would have to be a native Parsoid implementation of the maplink extension.

Jdforrester-WMF renamed this task from Listing numbers are all "1" at all Wikivoyages to MapLink extension tries to maintain global state (which isn't allowed), so Listing numbers are all "1" at all Wikivoyages in VE mode.Jul 12 2016, 7:25 PM
Jdforrester-WMF triaged this task as Medium priority.
Jdforrester-WMF moved this task from To Triage to TR1: Releases on the VisualEditor board.
MaxSem renamed this task from MapLink extension tries to maintain global state (which isn't allowed), so Listing numbers are all "1" at all Wikivoyages in VE mode to Kartographer relies on global state in Wikivoyage mode (which isn't allowed), so listing numbers are all "1" at all Wikivoyages in VE mode.Sep 23 2016, 7:37 AM
Jdforrester-WMF renamed this task from Kartographer relies on global state in Wikivoyage mode (which isn't allowed), so listing numbers are all "1" at all Wikivoyages in VE mode to Kartographer's Wikivoyage mode relies on global state (which isn't allowed), so listing numbers are all "1" at all Wikivoyages in VE mode and other issues.Jun 8 2017, 12:51 AM
Jdforrester-WMF added a project: Epic.

Brain dumping my preliminary investigation.

The feature in Kartographer related to this behavior in Wikivoyage https://www.mediawiki.org/wiki/Help:Extension:Kartographer#Groups

It means that templates that are built on top of {{listing}} in Wikivoayge create a mapframe/maplink under the hood that will have the data grouped into a global variable to be shared with a Dynamic Map at the top of the page during the MapFrame tag handler parsing stage.

Basically:

  1. it assembles an array of map data groups based on each tag (mapframe or maplink) in the page during onParserFirstCallInit and renders them saving the groups in the custom Kartographer/State class
  2. it pulls the groups data from a custom Kartographer/State class during onParserAfterParse and makes it available to the client-side interface through the global variable wgKartographerLiveData.

There are two reasons for groups.

  1. One is the Kartographer/State that is required for all maps with features. These are 'stable' groups and publish state, but are in themselves stateless. A single tag should create a stable id every single time you parse the same contents/attributes of that tag. (unless of course it embeds content which itself have state)
  2. But there is indeed also wikivoyage mode, where a map can collect OTHER coordinate entries in your page (for which it uses a counter) and then group all of those on a page and publish them as a group with a groupname. This state depends on what was parsed before it.

Both use the same State object and mechanisms, but I think from a Parsoid point of view the impact is different.
This state is published and consumed either via jsconfigvars (previews of all maps and pageviews of dynamic maps [(wikivoyage] mostly) or via the api (pageviews with static image fallbacks that are dynamically loaded). The key for a group is either a hash of the tag contents/params, or the name of the wikivoyage group. The keys are output as an attribute in the html, allowing the JS to find the associated state (via api or var).

MSantos added subscribers: ihurbain, MSantos.

Assigning it to @ihurbain to reflect reality since she is working on Kartographer/Parsoid compatibility.

We are keeping state in the legacy parser, but the Parsoid implementation solves the "everything is at [1]" issue. This feature is successfully deployed on enwikivoyage; deployment on other wikis will proceed along with T342871.