Help:Template limits: Difference between revisions

Content deleted Content added
document the unstrip post-expand size count, courtesy User:Izno
 
(12 intermediate revisions by 8 users not shown)
Line 1:
{{pp-vandalism|small=yes}}{{pp-move-indef}}
{{infopage|WP:TLIMIT|H:TLIMIT}}
 
The [[MediaWiki]] software that powers Wikipedia has several parameters that limit the complexity of a page, and the amount of data that can be included. These limits mainly concern data that is [[Wikipedia:Transclusion|transcluded]] or [[Wikipedia:Substitution|substituted]] during expansion of a page, as opposed to data directly in the source of the page itself. This page explains how and why these limits are applied, and how users can work within the limits.
Line 77:
 
== Post-expand include size ==
{{shortcut|WP:PEIS}}{{Tracked|T275319|open}}{{Tracked|T189108|open}}
The '''post-expand include size''' is the sum of the lengths of the expanded wikitexts generated by templates, parser functions and variables. Whenever the parser is instructed by the source code of a page to expand a template etc. (that is, to replace it by transclusion or substitution), the parser adds together the length of the expanded wikitext generated by the template etc. and the current counter value of the page. If this sum is more than the '''post-expand limit''' (same as the [[WP:CHOKING|max article size limit]]), the initial template etc. is not replaced and an error message is added as a comment in the output HTML. Otherwise the post-expand counter is increased to the new value, and parsing continues. A template that is expanded more than once in the page contributes more than once to its post-expand include size.
 
The '''post-expand include size''' is the sum of the lengths of the expanded wikitexts generated by templates, parser functions and variables. Whenever the parser is instructed by the source code of a page to expand a template etc. (that is, to replace it by transclusion or substitution), the parser adds together the length of the expanded wikitext generated by the template etc. and the current counter value of the page. If this sum is more than the '''post-expand limit''' (same as the [[WP:CHOKING|max article size limit]]; see <code>[[mw:Manual:$wgMaxArticleSize|$wgMaxArticleSize]]</code>), the initial template etc. is not replaced and an error message is added as a comment in the output HTML. Otherwise the post-expand counter is increased to the new value, and parsing continues. A template that is expanded more than once in the page contributes more than once to its post-expand include size.
Template invocations with no arguments have an expanded text cache. So if <code><nowiki>{{foo}}</nowiki></code> includes the second-level meta-template <code><nowiki>{{bar}}</nowiki></code>, then multiple invocations of <code><nowiki>{{foo}}</nowiki></code> will only increment the post-expand include size for the fully-expanded <code><nowiki>{{foo}}</nowiki></code>; the secondary include <code><nowiki>{{bar}}</nowiki></code> is only counted once. But if you included the same template multiple times with <code><nowiki>{{foo|arg}}</nowiki></code>, then the secondary templates are counted each time, even if the argument is the same.
 
Template invocations with no arguments have an expanded text cache. So if <code><nowiki>{{foo}}</nowiki></code> includes the second-level meta-template <code><nowiki>{{bar}}</nowiki></code>, then multiple invocations of <code><nowiki>{{foo}}</nowiki></code> will only increment the post-expand include size for the fully-expanded <code><nowiki>{{foo}}</nowiki></code>; the secondary includeinclusion <code><nowiki>{{bar}}</nowiki></code> is only counted once. But if you included the same template multiple times with <code><nowiki>{{foo|arg}}</nowiki></code>, then the secondary templates are counted each time, even if the argument is the same.
Pages exceeding the post-expand include size limit are automatically added to [[:Category:{{MediaWiki:post-expand-template-inclusion-category}}]] ([https://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle={{urlencode:Category:{{MediaWiki:post-expand-template-inclusion-category}}}}&cmprop=title%7Ctimestamp&cmlimit=500&cmsort=timestamp&cmdir=desc&format=xml recent additions]).
 
[[Template:Citations broken from PEIS limit]] may be manually added to the page when citations or templates are broken as a result of the issue. See also [[phab:T189108]].
Pages exceeding the post-expand include size limit are automatically added to [[:Category:{{MediaWiki:post-expand-template-inclusion-category}}]] ([https://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle={{urlencode:Category:{{MediaWiki:post-expand-template-inclusion-category}}}}&cmprop=title%7Ctimestamp&cmlimit=500&cmsort=timestamp&cmdir=desc&format=xml recent additions]). [[Template:Citations broken from PEIS limit]] may be manually added to the page when citations or templates are broken as a result of the issue.
 
=== Using comments, noinclude and onlyinclude ===
Only data that survives the preprocessor expansion stage is counted towards the post-expand counter. The length of HTML comments in the wikitext (which are not reproduced in the HTML source produced) is not included in the post-expand counter. Code which is either inside a &lt;{{xtag|noinclude&gt;}} section or outside an &lt;{{xtag|onlyinclude&gt;}} section does not get expanded, so these sections do not contribute to the post-expand size. This also means that category tags only contribute if they are included (to categorize pages calling the template).
 
===Nested transclusions===
Note that the sizes of the wikitexts of all expanded templates and parser functions are added, even in the case of nesting (see [[phab:T15260]]), so extra levels increase the count. If page A transcludes B and B does nothing but transclude C, then the size of C will be counted ''twice'' towards the post-expand include size on page A, and similarly if a template consists of a parser function call, or a parser function has a template call as parameter, etc. Possible substitutions to reduce nesting include:
 
*<code><nowikisyntaxhighlight lang="wikitext" inline>{{#if:{{{test|}}}|{{template1}}|{{template2}} }}</nowiki></codesyntaxhighlight> replaced with <code><nowikisyntaxhighlight lang="wikitext" inline>{{ {{#if:{{{test|}}}|template1|template2}} }}</nowiki></codesyntaxhighlight>.
*{{tl|navboxes}} replaced with {{tl|navboxes top}} and {{tl|navboxes bottom}}
*{{tl|trim|...}} replaced with {{pf|if|1|...}}
* {{tlf|Episode table|episodes{{=}}...}} -> <code><nowikisyntaxhighlight lang="wikitext" inline>{{episode table|dontclose=y}} ...</ {{End|html=y|Episode table></nowiki>}}</codesyntaxhighlight>
 
=== Non-rendered transclusions ===
Non-rendered tranclusions still count towards limit. For example, a page which contains only <code><nowikisyntaxhighlight lang="wikitext" inline>{{#if:{{:Main Page}}}}</nowiki></codesyntaxhighlight> would still have a post-expand include size even though it would have no output at all.
 
The same applies to [[Wikipedia:Lua|Scribunto modules]]. For example, <code><nowikisyntaxhighlight lang="wikitext" inline>{{#invoke:Test|main}}</nowiki></codesyntaxhighlight> would still increase post-expand include size even if Module:Test were simply: <syntaxhighlight lang=lua>mw.getCurrentFrame():preprocess'{{msgnw::Main Page}}' -- remove this line and post-expand include size becomes zero
return { main = function() end } -- p.main() has no return value</syntaxhighlight>
 
Line 108:
* {{ml|infobox|infoboxTemplate}}, {{ml|infobox3cols|infoboxTemplate}} inside infobox templates.
* {{ml|flag|}}, {{ml|flagg|}} for articles with large numbers of flags.
* {{ml|cite |web|}}, {{ml|cite |news|}}, e.g. where there are several hundred references.
* {{ml|episode table|main}}, {{ml|episode list|}} for episode lists.
 
Line 122:
Example:
 
<code><nowiki>{{tlx|3x|{{tlp|2x|abcde}}}}</nowiki></code> has a template argument size of 40 bytes: the argument <code>{{2x|abcde}}</code> is counted 3 times, the argument <code>abcde</code> twice.
 
Arguments in the template call which do not match any parameter tag in the template do not count.
Line 136:
 
== Expensive parser function calls ==
{{Redirect|WP:EXPENSIVE|the essay "Redirects are costly"|WP:COSTLY}}{{Further|mw:Manual:$wgExpensiveParserFunctionLimit|Template:Expensive}}{{shortcut|WP:EXPENSIVE}}
{{shortcut|WP:EXPENSIVE}}
 
There is a limit of 500 to the '''expensive parser function count''', i.e., the number of calls of expensive [[:mw:Help:Magic words#Parser functions|parser functions]], which are:
* <code>[[Help:Magic words#Conditional|#ifexist]]<nowiki /code>ifexist: [[Help:Conditional expressions|conditional expression]] which branchingbranches depending on whether a particulargiven page exists or not. If the limit on thisexpensive counterparser functions is exceeded, every additional <code>#ifexist</code> callscall will actbehave as though the pagesgiven theypage in the query dodoes not exist.
* [[mw:Help:<code>{{Magic words#Statisticsword|PAGESINCATEGORY]]}}</code> or PAGESINCAT: Number of pages in the category named ''categoryname''. Each subcategory is counted as one item.
* [[mw:Help:Magic words#Technical metadata|PAGESIZE]]
* CASCADINGSOURCES
Line 158 ⟶ 157:
 
==Unstrip post-expand size==
The '''unstrip post-expand size''' counter tracks the total bytes added via [[HelpWikipedia:TemplateStyles|TemplateStyles]] (the {{tag|templatestyles|e}} tag itself is counted towards the [[#Post-expand include size|post-expand include size]] count).
 
==#time==
Line 174 ⟶ 173:
 
==References==
* [[:Special:PermanentLink/70023682#New template limits.2C Special:ExpandTemplates|Village pump technical]] (discussion now moved to [[Wikipedia talk:Template limits]])
* [http://lists.wikimedia.org/pipermail/wikipedia-l/2006-August/027271.html Tim's posting on wikipedia-l]
* [[mw:NewPP parser report]]