Page MenuHomePhabricator

Arbitrary Wikidata access on Commons trigers expansion depth limit
Closed, ResolvedPublic

Description

I was looking in a way to get date in ISO format from wikidata and the best way seems to be "{{str sub|{{Data|item=Q79822|property=p569|displayformat=raw}}|1|10}}" using module:Wikidata (same LUA code on Commons and Wikidata). The operation has 2 steps:

  1. {{Data|item=Q79822|property=p569|displayformat=raw}} returns " 1798-12-24T00:00:00Z"
  2. {{str sub| 1798-12-24T00:00:00Z|1|10}} trims it to 1798-12-24

The first step uses up 4 expansion depths the second 3. However combined they use up 41 out of 40 expansion depths and trigger "Expansion depth limit exceeded" error.
There might be a better way to get ISO-date from Wikidata (let me know how if you know), but I run into "Expansion depth limit exceeded" error several times while using wikidata returns in Commons templates.

Below is the report on a page with only "{{str sub|{{Data|item=Q79822|property=p569|displayformat=raw}}|1|10}}"
<!--
NewPP limit report
Parsed by mw1219
Cached time: 20160428152934
Cache expiry: 2592000
Dynamic content: false
CPU time usage: 0.535 seconds
Real time usage: 0.548 seconds
Preprocessor visited node count: 229/1000000
Preprocessor generated node count: 0/1500000
Post‐expand include size: 10015/2097152 bytes
Template argument size: 3257/2097152 bytes
Highest expansion depth: 41/40
Expensive parser function count: 1/500
Lua time usage: 0.113/10.000 seconds
Lua memory usage: 4.5 MB/50 MB
Number of Wikibase entities loaded: 0-->

<!--
Transclusion expansion time report (%,ms,calls,template)
877.40% 4800.341 13 - Template:Data
100.00% 547.111 1 - Template:Str_sub
100.00% 547.111 1 - -total
-->

Event Timeline

Similar problem with Lua triggering "expansion depth" occurred lately and was discussed in great detain at https://en.wikipedia.org/wiki/Wikipedia_talk:Lua#trouble_with_Expansion_depth the problem was solved by rewriting one of several Lua codes which was not managing properly 'frame" parameters. It probably does not have anything to do with Wikidata, except that it happen first time when accessing it.

I am no longer convinced that there is anything to fix here, except maybe better error messages in Lua when hitting Expansion depth and maybe some documentation on how to avoid it. I still do not understand it well.

Jarekt claimed this task.