![]() | This is an essay. It contains the advice or opinions of one or more Wikipedia contributors. This page is not an encyclopedia article, nor is it one of Wikipedia's policies or guidelines, as it has not been thoroughly vetted by the community. Some essays represent widespread norms; others only represent minority viewpoints. |
This essay covers issues about the MediaWiki version 1.16 "expansion depth limit" for the nesting of templates and if-logic. All during 2009-2016, the nesting limit has been only a mere 40 levels of nested if-then-else (or nested templates) invoked inside other templates (it was later set to 100 levels in 2021). Some templates end up being counted twice in this list. NOTE THE DANGER: When the depth limit is exceeded, not all templates die, but rather, they simply generate the wrong results (from the remainder of the template) and keep going, as if nothing were wrong. The limits were chosen to thwart denial of service (DoS) attacks being caused by very large or complex templates.
What is not affected: Typically, large templates can be invoked, together, in article text without reaching the limit. The main worry is when using large templates inside an infobox or deeper inside the coding of other templates (when editing a large template). Using large templates together in an article paragraph is rarely a problem.
Reducing expansion depth: The nest-levels can be reduced, inside large templates, by rewriting some of the nested if-else-if-else logic as non-nested if-then-if-then-if-then, or using a #switch outside of the if-then logic. In some cases, avoiding the use of other templates inside a template can also reduce the nesting: whereas using a #ifexpr increases the depth by 1 level, invoking another template containing that #ifexpr increases depth by 2 levels. Putting a default value in a parameter does NOT increase the nesting level: {{{1}}} and {{{1|78.5}}} are both at zero (0) levels of nesting.
© MMXXIII Rich X Search. We shall prevail. All rights reserved. Rich X Search