Is there a way to calculate/query the number of templates in a wiki article?
The goal is to identify pages on our wiki that transclude excessive numbers of templates,
flag them as too complex,
and work with page authors to reduce their complexity.
For example, if page P transcludes {{foo}} ten times and {{bar}} two times, the count
would be 12.
(We don't care about recursive transclusions for now.)
Special:MostLinkedTemplates does the opposite (identifies highly linked templates, not
highly-templated pages).
I also queried the templatelinks table, but it seems to count each template only once, not
multiple transclusions of the same template.
SQL or PHP solutions would be fine. I suspect we could attach a callback to the hook
'BeforeParserFetchTemplateAndTitle'
and count the fetches, but I'd prefer something that won't impact the running
wiki.
Another approach might be to reduce the $wgMax*PPNodeCount values, but choosing
appropriate values
would be trial and error.
Thank you!
DanB