[go: up one dir, main page]

Page MenuHomePhabricator

High volume of un-servable requests for static map thumbnails to www.wikidata.org Special:BlankPage
Closed, ResolvedPublic

Description

Half of the "groupIds not available" log messages, roughly 60k requests per day, are being made for impossible maps on Wikidata's Special:BlankPage. An example URL is https://maps.wikimedia.org/img/osm-intl,13,36.814892,-5.744377,310x180.png?lang=en&domain=www.wikidata.org&title=Special%3ABlankPage&groups=_205a9df43a110cb2362515b6d3674c0071e3433f .

These image links are made when browsing a Wikidata entity page with maps, for example https://www.wikidata.org/wiki/Q513

Note that due to this bug, map thumbnails will not have annotations (such as the coordinate marker) on no-script browsers.

The fix is very simple: we need to fill the title parameter with the entity name. The mapdata API already serves these requests correctly. For example, here the title has been supplied:
https://maps.wikimedia.org/img/osm-intl,13,27.988055555556,86.925277777778,310x180.png?lang=en&domain=www.wikidata.org&title=Q513&groups=_61b46232823592e723c88ef29f5e45429366e567 . Note that the revid parameter should also be included.

Event Timeline

awight renamed this task from High volume of requests for static map thumbnails to www.wikidata.org Special:BlankPage to High volume of un-servable requests for static map thumbnails to www.wikidata.org Special:BlankPage.Jun 1 2022, 11:32 AM
awight updated the task description. (Show Details)

Thanks Adam! Do you want to provide a patch?

I don't have a local Wikibase installation for development, but I would be happy to pair with a Wikidata/Wikibase developer any time!

Change 803578 had a related patch set uploaded (by Awight; author: Awight):

[mediawiki/extensions/Wikibase@master] Include the current page title in static mapframe image URL

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

For most of the current problems the given patch should be good enough though (and it's definitely an improvement)!

Referring to https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/803578/1: How to pass the page tite/ revision id into CachingKartographerEmbeddingHandler:
I looked into this for a bit and I think the only somewhat nice option we currently have is to add these to FormatterOptions: A revision id (int) and a TitleValue (which both default to null, in which case we fetch using the main RequestContext in CachingKartographerEmbeddingHandler).

I think I agree that FormatterOptions is the best option we have, but even so, it’s not great :/ we’ll need to get this information into some of the relevant places that create the options (e.g. WikibaseHtmlSnakFormatterFactory::getSnakFormatter()).

I looked through the other data types, and I think this might be the first / only data type that needs the current page title and revision ID to order a data value. ScoreFormatter uses a Parser when rendering musical notation values, but only for interaction with Score features that aren’t used when formatting musical notation values, I think (e.g. the override_midi option), and it doesn’t access the “context” of the parser either.

There's a completely different direction we could go in, which would mean adding some non-trivial functionality to kartotherian but would greatly simplify the integration here. The mapframe tag could support a new attribute like marker="center" which would plot a simple marker at the center coordinates. This requires no round-trip from the server back to MediaWiki. The limitation is that we couldn't show multiple markers or geoshapes, but I think it would be sufficient for this one use case.

For example, this page has the contents:

<mapframe latitude="35.677" longitude="139.774" zoom="6" width="400" height="300" align="right" />

Since there is no child text inside the mapframe element, it avoids the round-trip and its thumbnail URL looks like https://maps.wikimedia.org/img/osm-intl,6,35.677,139.774,400x300.png?lang=en .
I'm proposing a new attribute and URL parameter that would look like,

<mapframe latitude="35.677" longitude="139.774" zoom="6" width="400" height="300" align="right" marker="center" />

and an URL like, https://maps.wikimedia.org/img/osm-intl,6,35.677,139.774,400x300.png?lang=en&marker=center

That would be lovely for our use case, at least – putting all the needed information into the URL, so the coordinate data value can be rendered without any extra information.

[...]
I'm proposing a new attribute and URL parameter that would look like,

<mapframe latitude="35.677" longitude="139.774" zoom="6" width="400" height="300" align="right" marker="center" />

and an URL like, https://maps.wikimedia.org/img/osm-intl,6,35.677,139.774,400x300.png?lang=en&marker=center

That also sounds like a viable solution to me, but I'm not sure it's preferable to the FormatterOptions approach above (AFAIS we would probably be the only users for this and I have never touched kartotherian myself).

As CommonsInlineImageFormatter currently accesses ParserOptions::getThumbSize (in WikibaseValueFormatterBuilders::newCommonsMediaFormatter these are also taken from RequestContext::getMain), going the route described above, we could also cater to that use case (and remove the need for global state here).

This bug is responsible for the biggest share of errors from kartotherian. Please adapt the POC patch and let us know if we can help!

Change 803578 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Include the current page title in static mapframe image URL

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

awight claimed this task.

Congratulations and thank you for the patch! It looks like this issue was fixed as of Feb 1:

image.png (288×957 px, 18 KB)