Content deleted Content added
(83 intermediate revisions by 45 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 8:
The [[MediaWiki]] software, which generates the [[HTML]] of a page from its wiki source, uses a [[parser]] to deal with included data. This is done using a "preprocessor" which converts the wikitext into a data structure known as an XML tree, and then uses this tree to produce "[[m:Help:Expansion|expanded]]" wikitext, where double- and triple-braced structures are replaced by their result.
During the conversion process, the software uses several counters to track the complexity of the page that is being generated. When the [[parsing]] of a page begins, these counters are set to zero, but they are incremented during the parsing process, as described below. There are upper limits on these counters, and the parser does not allow these limits to be exceeded.
===Why are there limits?===
Line 14:
===Working within the limits===
When a page reaches the template limits, the most common solution is to make the templates shorter, using methods described below. If this isn't possible, it may be necessary to include more data directly in the page source, rather than transcluding it from templates (e.g., formatting references by hand or using <code><nowiki><references /></nowiki></code> instead of
===When do problems arise?===
Line 21:
===How can you find out?===
Once the page body is processed, an HTML comment is added towards the end of the HTML code of the page with the final values of the various counters. For example, the page [[HIV/AIDS]] (on
<
<!--
NewPP limit report
Parsed by mw1416
Preprocessor node count: 173488/1000000▼
Cached time: 20231227101515
Post-expand include size: 1557895/2048000 bytes▼
Cache expiry: 2592000
Template argument size: 561438/2048000 bytes▼
Reduced expiry: false
Highest expansion depth: 29/40▼
Complications: [vary‐revision‐sha1, show‐toc]
Expensive parser function count: 7/500▼
Real time usage: 3.151 seconds
Unstrip recursion depth: 1/20
Unstrip post‐expand size: 1121339/5000000 bytes
Lua time usage: 1.705/10.000 seconds
Lua Profile:
MediaWiki\Extension\Scribunto\Engines\LuaSandbox\LuaSandboxCallback::preprocess 180 ms 10.6%
? 160 ms 9.4%
MediaWiki\Extension\Scribunto\Engines\LuaSandbox\LuaSandboxCallback::callParserFunction 140 ms 8.2%
MediaWiki\Extension\Scribunto\Engines\LuaSandbox\LuaSandboxCallback::plain 140 ms 8.2%
MediaWiki\Extension\Scribunto\Engines\LuaSandbox\LuaSandboxCallback::gsub 80 ms 4.7%
MediaWiki\Extension\Scribunto\Engines\LuaSandbox\LuaSandboxCallback::find 80 ms 4.7%
dataWrapper <mw.lua:672> 80 ms 4.7%
select_one <Module:Citation/CS1/Utilities:426> 80 ms 4.7%
recursiveClone <mwInit.lua:41> 80 ms 4.7%
<mwInit.lua:41> 60 ms 3.5%
[others] 620 ms 36.5%
Number of Wikibase entities loaded: 0/400
-->
</syntaxhighlight>
(Some items may not be present on other wikis, depending on which extensions they have installed; for example, the "Lua" items are added by [[mw:Extension:Scribunto|Extension:Scribunto]].)
Because of the way the counters are increased, the
Click "Parser profiling data" at the bottom of a preview to see similar data for the preview without saving it.
NewPP limit report▼
▲Lua time usage: 0.331s
▲Lua memory usage: 1.25 MB
==Expansion==
Line 58 ⟶ 69:
== Preprocessor node count ==
{{see also|mw:Manual:$wgMaxPPNodeCount}}
The '''preprocessor node count''' measures the complexity of the page (not the volume of data). As the parser is expanding a page, it creates a data structure known as a tree that corresponds to the HTML structure of the page. Each node of the tree that is visited during expansion is counted towards the preprocessor node count. If this count is exceeded, the parser will abort parsing with the error "Node-count limit exceeded" visible in the generated HTML.
The count starts with 1 for plain text. A pair of nowiki tags counts for 3, a header for 2, etc. A link does not contribute to the count. For the expansion of <code>#switch</code> every checked condition adds 2 to the count. In the case of multiple expansions of the same template the content of a template without arguments counts only once, but that of a template with arguments (even if constant) counts multiple times. In contrast to this, the result of an expansion can be used multiple times while counting only once if it is assigned to a template parameter, and
Pages exceeding this limit are automatically categorized into [[:Category:Pages where node count is exceeded]] ([https://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category%3APages%20where%20node%20count%20is%20exceeded&cmprop=title%7Ctimestamp&cmlimit=500&cmsort=timestamp&cmdir=desc&format=xml recent additions]).
== 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]]; 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
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
===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 [
*{{tl|navboxes}} replaced with {{tl|navboxes top}} and {{tl|navboxes bottom}}
*{{tl|trim|...}} replaced with {{pf|if|1|...}}
*{{tlf|Episode table|episodes{{=}}...}} -> <syntaxhighlight lang="wikitext" inline>{{episode table|dontclose=y}} ... {{End|html=y|Episode table}}</syntaxhighlight>
=== Non-rendered transclusions ===
Non-rendered tranclusions still count towards limit. For example, a page which contains only <syntaxhighlight lang="wikitext" inline>{{#if:{{:Main Page}}}}</syntaxhighlight> 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, <syntaxhighlight lang="wikitext" inline>{{#invoke:Test|main}}</syntaxhighlight> 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>
=== #invoke syntax ===
{{anchor|invoke syntax}}
Some templates have equivalent Lua modules, which may be transcluded with the syntax <code>#invoke:''module name''</code>. This has lower PEIS than using templates which wrap that Lua module. However, if used directly in articles there is a cost to the readability (and editing) of article source code, so that is discouraged unless strictly necessary. These include:
* {{ml|navbox|navbox|...}}, {{ml|navbox with collapsible groups|navbox|...}}, inside navbox templates.
* {{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.
=== References ===
Pages may exceed the limit when trying to display references using the {{tl|reflist}} template. Replacing it with <code><nowiki><references /></nowiki></code> may allow the references to appear, although the list may be truncated if the limit is exceeded by templates such as {{tl|cite web}}. As of 2010, the <references /> tag has the same font styling as {{tl|reflist}}, and as of 2017 it allows for responsive columns.
=== Splitting articles ===
Ideally the length of articles would be determined by content-related decisions not technical issues. However, if PEIS issues are unresolvable on an article such as a long list, it may be split into sections which each fit within the limit, following the policy at [[WP:SPLIT]].
==Template argument size==
The
Example:
Arguments in the template call which do not match any parameter tag in the template do not count.
Line 97 ⟶ 128:
If a template contains a switch, use of template arguments beyond a match do not count. Up to and including the matching case, template arguments used on the left of the equals signs count twice. Those on the right of the equals sign count for the matching case only.
Pages exceeding the template argument size limit are automatically added to [[:Category:Pages containing omitted template arguments]] ([https://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category%3APages_containing_omitted_template_arguments&cmprop=title%7Ctimestamp&cmlimit=500&cmsort=timestamp&cmdir=desc&format=xml recent additions]).
==Highest expansion depth==
{{See also|m:Help:Expansion depth|mw:Manual:$wgMaxTemplateDepth}}
{{more|Wikipedia:Avoiding MediaWiki expansion depth limit}}
Pages exceeding this limit are automatically categorized into [[:Category:Pages where expansion depth is exceeded]] ([https://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category%3APages_where_expansion_depth_is_exceeded&cmprop=title%7Ctimestamp&cmlimit=500&cmsort=timestamp&cmdir=desc&format=xml recent additions]).
== Expensive parser function calls ==
{{Redirect|WP:EXPENSIVE|the essay "Redirects are costly"|WP:COSTLY}}{{Further|mw:Manual:$wgExpensiveParserFunctionLimit|Template: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
*
* [[mw:Help:Magic words#
* CASCADINGSOURCES
* REVISIONUSER, when used on a page other than the current page
Line 117 ⟶ 148:
** [[mw:Extension:Scribunto/Lua reference manual#mw.site.stats.pagesInCategory|mw.site.stats.pagesInCategory]]
** Some [[mw:Extension:Scribunto/Lua reference manual#Title objects|title object]] properties and methods
* [[mw:Extension:SyntaxHighlight|{{tag|syntaxhighlight}} tags]]
It is also possible to manually increment the expensive parser function count from a Lua module by using [[mw:Extension:Scribunto/Lua reference manual#mw.incrementExpensiveFunctionCount|mw.incrementExpensiveFunctionCount]].
Pages that exceed this limit are automatically categorized into [[:Category:Pages with too many expensive parser function calls]] ([https://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Pages_with_too_many_expensive_parser_function_calls&cmprop=title%7Ctimestamp&cmlimit=500&cmsort=timestamp&cmdir=desc&format=xml recent additions]).
See also: [[mw:Manual:$wgExpensiveParserFunctionLimit]], [[Template:Expensive]]▼
==Unstrip post-expand size==
▲See also: [[mw:Manual:$wgExpensiveParserFunctionLimit]]
The '''unstrip post-expand size''' counter tracks the total bytes added via [[Wikipedia:TemplateStyles|TemplateStyles]] (the {{tag|templatestyles|e}} tag itself is counted towards the [[#Post-expand include size|post-expand include size]] count).
==#time==
The total length of the format strings of function <code>#time</code> is limited to 6000 characters [
Unfortunately, the count is not in the limit report.
== Special:Expandtemplates ==
When a page exceeds the limits, one crude way to solve the problem is to use [[Special:ExpandTemplates]]. As opposed to [[WP:SUBST|substitution]] it recursively expands all levels at once, without the need of specially preparing the templates with the code <code><nowiki>
==History==
The inclusion limits were put into effect on the English Wikipedia by [[User:Tim Starling|Tim Starling]] on 14 August 2006. A new preprocessor was [[m:Migration to the new preprocessor|enabled in January 2008]], removing the "pre-expand include limit" and replacing it with a "preprocessor node count" limit.
The practice of using a template documentation page, while it can still be useful for other reasons, is no longer needed for avoiding documentation to be counted on pages that call the template.
==References==
* [
* [http://lists.wikimedia.org/pipermail/wikipedia-l/2006-August/027271.html Tim's posting on wikipedia-l]
{{Wikipedia technical help|collapsed}}
[[Category:Wikipedia template
|