Page MenuHomePhabricator

Error: Template loop detected - limited recursions should be allowed.
Closed, DeclinedPublic

Description

In a private Wiki. I made a simple template having 10 parameters.
With Extension:Parserfunctions, it tests the wiki page given as
its 1st parameter:

  • if omitted or empty, the template does nothing, else
  • if the pages exists, it yields a (blue) link to it, else
  • if emits a (red) link and calls itself recursively with parameters shifted one down.

Called at the end of wiki pages, it allow one to see which
other consecutive pages are planned but not created, and to
continue reading at the next existing page. This appears
sane, imho, especially, since 10 is not a large number.

I declines work however, saying "template loop detected"

Of course, you can always "flatten" a known (max) number
of recusions, but the result is an awfully huge template,
with many duplicated lines of code.

Is there a chance to have a $wgTemplateLoopLimit installation
setting which would make MediaWiki more flexible?

I would naively recommend a default $wgTemplateLoopLimit = 2
so as to accomodate templates that document themselves with
sample calls.

If that can be had without restructuring or rewriting the parser,
I might give it a try myself.


Version: 1.17.x
Severity: enhancement

Details

Reference
bz25644

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 11:14 PM
bzimport set Reference to bz25644.
bzimport added a subscriber: Unknown Object (MLST).

(In reply to comment #0)

If that can be had without restructuring or rewriting the parser,
I might give it a try myself.

Did you give it a try? Also, don't fear the parser! ;)

I did not have the time to look into it yet, but maybe it is an option to do so during the upcoming Hackaton :-) where all the experts are about.

We should be able to get the value of "{{Factorial|2}}" by using a template such as the following [[Template:Factorial]]:

{{#ifexpr: {{{1|0}}} < 2

1
{{Factorial
{{#expr: {{{1}}}
 *{{Factorial|
   {{#expr: {{{1}}} - 1 }}
  }}
}}

}}

}}

Currently, all we get is "Template loop detected" =(

Maybe the new parser could handle this? (adding "newparser" keyword)

Unsure if this request (adding a $wgTemplateLoopLimit setting) still makes sense now that we have Lua/Scribunto which makes template execution way faster, hence proposing WONTFIX here.

http://en.wikipedia.org/wiki/Wikipedia:Template_limits#How_can_you_find_out.3F explains how to find out if limitations are set (and I assume this applies to any wiki, not just Wikimedia ones).

If you have questions about Lua, please post on http://en.wikipedia.org/wiki/Wikipedia_talk:Lua , and see http://www.mediawiki.org/wiki/Lua_scripting and http://blog.wikimedia.org/tag/lua/ for more information.

(In reply to comment #5)

Unsure if this request (adding a $wgTemplateLoopLimit setting) still makes
sense now that we have Lua/Scribunto which makes template execution way
faster, hence proposing WONTFIX here.

Scribunto is not only faster, it also has looping constructs, and much cleaner syntax for this sort of thing. WONTFIX sounds good to me.