Jump to content

Template talk:High-use

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Include mainspace count

[edit]

Instead of just taking the number of transclusions and dividing by {{NUMBEROFPAGES}} (which is currently 63,227,481), I was thinking it might make for a more cautionary warning to also show how big the number is compared to {{NUMBEROFARTICLES}}. See [1] for the sandboxed change. Basically, this would cause the template to look like this:

Naturally, not all templates that use {{High-use}} are used in mainspace, so I can see how this change could be a little confusing, but I think it would still make the percent number more meaningfully cautionary. For example, Template:Short description says that the template is used on "10% of all pages", which honestly feels like not a big number—it would more clearly impress upon the layperson the gravity of the situation if it said "92% of all mainspace articles". Template:WikiProject banner shell would say: "This template is used on approximately 11,300,000 pages, which is roughly 161% of all mainspace articles or 18% of all pages." Mz7 (talk) 06:50, 29 May 2025 (UTC)[reply]

@Mz7 I'm worried that would be a bit misleading, as it would result in things like {{WikiProject banner shell}} saying that it's being used on 163% of mainspace articles. If there's a strong desire to include this information I could look into having Ahechtbot tabulate mainspace transclusions in addition to all transclusions, but that would cause a significant increase in runtime and require breaking changes to the data pages. --Ahecht (TALK
PAGE
)
18:13, 29 August 2025 (UTC)[reply]
Just adding that I already did this experiment back in 2021, and running the transclusion count query limited to the article namespace wasn't feasible (it just sat there for three hours before timing out, compared to 10-20 minutes for the all-namespace query). --Ahecht (TALK
PAGE
)
18:54, 10 October 2025 (UTC)[reply]

TemplateStyles

[edit]

There are a few high-use template styles, e.g., Template:Sister project/styles.css, which have no such indication (as they do not have documentation subpages). In my own private wiki, I have provided an analogous notice via the top icon indicator as these are still processed within CSS comments. My Module:High-use has been changed as follows:

local function showIndicator()
	return mw.getCurrentFrame():preprocess([=[
{{#tag:indicator|<span class="plainlinks" style="background-color:pink;">[[WP:High-risk templates|High-use]]:[https://linkcount.toolforge.org/?project=en.wikipedia.org&page={{urlencode:{{FULLPAGENAME}}}}#transclusions {{#invoke:transclusion count|fetch}}]</span>|name=High-use}}]=])
end

function p._main(args, nocat)
	local contentModel = mw.title.getCurrentTitle().contentModel
	if contentModel == "css" or contentModel == "sanitized-css" then
		return showIndicator()
	end
-- remainder of function

If you think this is useful on Wikipedia, I can make the associated changes for all but non-admin protected pages. Dpleibovitz (talk) 17:14, 16 July 2025 (UTC)[reply]

Edit request 27 August 2025: refactor

[edit]

Description of suggested change: I've refactored the module code to make it:

  • easier to understand (added comments)
  • easier to localize
  • have less repeated code
  • use |demo= as the title everywhere, including in the Toolforge link, if provided
  • use the base page for /testcases pages as well as /doc and /sandbox
  • use Lua for the system categorization code instead of preprocessing a string containing {{sandbox other}}, a switch statement, and a Module:Effective protection level invocation

My code is in Module:High-use/sandbox and the test cases are at Template:High-use/testcases. Please check my code and update the main module if it looks good!

Diff: sandbox diffCalendulaAsteraceae (talkcontribs) 08:28, 27 August 2025 (UTC)[reply]

Answering your post at Wikipedia:Village pump (technical) § Code review for Module:High-use refactor here because this is a better venue.
Add require ('strict') which will help find globals that ought not be globals, etc.
For i18n, consider rewriting count_from_args() (lines 18–36 – permalink); mayhaps sommat like this:
require ('strict');

local lang_obj = mw.getContentLanguage()										-- this here because the language object is used multiple places in the module

local function count_from_args(args_t)
	if tonumber(args_t.count) then												-- check if function has already been used
		return count;															-- early exit if already used
	end

	local count;	

	if count == nil and yesno(args_t['fetch']) == true then						-- '== true' instead of '~= false'
		count = _fetch(args_t)													-- fetch transclusion count
	end
	
	if count == nil and args_t[1] ~= nil and args_t[1] ~= '' then				-- use explicitly-provided count when fetch fails
		count = math.floor (lang_obj:parseFormattedNumber (args_t[1]));			-- convert local language number string to a number understandable by lua
	end
	
	return count > 0 and count or nil;											-- incase someone writes a negative number
end
Trappist the monk (talk) 16:35, 29 August 2025 (UTC)[reply]
Thank you, implemented! I think the current code does use _fetch if args['fetch'] is nil, so I've left that as-is. —CalendulaAsteraceae (talkcontribs) 21:25, 29 August 2025 (UTC)[reply]
It looks like you've implemented hooks to show percentage of articles in addition to all pages. See the section above for my concerns there. We can tabulate mainspace usage separately with the bot, but it's not worth the effort unless there's actual consensus to include it. --Ahecht (TALK
PAGE
)
19:09, 29 August 2025 (UTC)[reply]
TBH I just left that in because someone else had been working on it, no problem to take that out. —CalendulaAsteraceae (talkcontribs) 21:20, 29 August 2025 (UTC)[reply]
@Ahecht, @Trappist the monk, how does the updated code look? —CalendulaAsteraceae (talkcontribs) 03:45, 14 September 2025 (UTC)[reply]
@CalendulaAsteraceae My only concern is using the base page name for the sandbox. There are sub-templates that are listed in Module:Transclusion_count/data/ that likely have their own sandboxes. For example, the "high use" message at Module:Adjacent stations/Amtrak correctly links to Module:Adjacent stations/Amtrak/sandbox. For the sandbox, the existing logic that only uses the basePageTitle if it ends in "doc" or "sandbox" is fine. For the testcases, I might see an argument to strip "doc" and "sandbox", check if that testcases page exists (although I'd do it with getContent() since for some reason exists is expensive but getContent() isn't), and if not use the base page title. --Ahecht (TALK
PAGE
)
15:39, 14 September 2025 (UTC)[reply]
@Ahecht, done. —CalendulaAsteraceae (talkcontribs) 03:34, 15 September 2025 (UTC)[reply]
@Ahecht, thoughts on the updated code? —CalendulaAsteraceae (talkcontribs) 21:54, 3 October 2025 (UTC)[reply]
@CalendulaAsteraceae The testcases look fine to me. I haven't had a chance to dive into the code, but if you're willing to take ownership then go for it. --Ahecht (TALK
PAGE
)
18:49, 4 October 2025 (UTC)[reply]
@Ahecht: Thank you! I don't have permissions to edit Module:High-use, but if you copy over my latest edits at Module:High-use/sandbox, I'm happy to keep an eye on things and fix any issues that come up. —CalendulaAsteraceae (talkcontribs) 05:27, 5 October 2025 (UTC)[reply]
 Done --Ahecht (TALK
PAGE
)
13:57, 7 October 2025 (UTC)[reply]
Thank you! —CalendulaAsteraceae (talkcontribs) 21:53, 7 October 2025 (UTC)[reply]

Transcluding nonexistent /testcases pages

[edit]

This change appears to have caused {{Taxonomy/Salticidae}} to transclude {{Taxonomy/Salticidae/testcases}}, which does not exist. This new issue is happening at a few hundred or more Taxonomy templates. See Wikipedia:Database reports/Transclusions of non-existent templates for the list. It is also happening at some non-Taxonomy templates, like {{Tab/Number of defined parameters}}. – Jonesey95 (talk) 18:09, 8 October 2025 (UTC)[reply]

We can fix that by using exists instead of getContent. I think that'll be OK even though it's an expensive function, since the template is only called once per page, and Template:High-use/testcases is fine even though it calls the template a lot. @Ahecht, could you copy over my changes from Module:High-use/sandbox? —CalendulaAsteraceae (talkcontribs) 20:20, 8 October 2025 (UTC)[reply]
 Done --Ahecht (TALK
PAGE
)
20:24, 8 October 2025 (UTC)[reply]
It looks like that worked. There are about half a dozen fully protected pages still causing /testcases transclusions to show up on the report, but they will clear on their own. – Jonesey95 (talk) 16:00, 9 October 2025 (UTC)[reply]
It's also fixed Wikipedia:Database reports/Broken WikiProject templates. --Redrose64 🌹 (talk) 16:06, 10 October 2025 (UTC)[reply]

Edit request 27 September 2025

[edit]

Description of suggested change: can we get a |testcase= that will allow you to supply a link to where the testcases are located that will replace the default of ''base_template''/testcase? The reason for this is Modules. The testcases cannot be located at Module:Person height/testcases (for example) and are more likely to be located at Template:Infobox person/height/testcases. —Zackmann (Talk to me/What I been doing) 08:42, 27 September 2025 (UTC)[reply]

Actually they can be located at Module:Person height/testcases; you can use Special:ChangeContentModel to create a wikitext page there, or move an existing wikitext page there (and click through the edit filter warning). I'd be more inclined to just do so and create a redirect rather than convoluting up the template, but if another TPE wants to code and implement this I guess they can do so. * Pppery * it has begun... 16:24, 27 September 2025 (UTC)[reply]
@Pppery: well… You learn something new everyday! Thanks a ton. Didn’t know about Change Context Model. — Zackmann (Talk to me/What I been doing) 18:21, 27 September 2025 (UTC)[reply]
@Zackmann08 You don't even have to change the content model. The default used by the {{documentation}} template (used by nearly all modules) is to locate the testcases at Module:Foo/testcases, and it prepopulates that module page with Template:Documentation/preload-module-testcases which uses Module:UnitTests to create the testcases. You then run it by going to Module talk:Foo/testcases. --Ahecht (TALK
PAGE
)
18:55, 27 September 2025 (UTC)[reply]
@Ahecht: that seems complicated…[sarcasm]. Thanks for the info though!!! —Zackmann (Talk to me/What I been doing) 19:03, 27 September 2025 (UTC)[reply]

Used in system

[edit]

There is a discussion over at Template talk:Used in system#documentation out of date? you might be interested in. Regards CapnZapp (talk) 11:05, 5 October 2025 (UTC)[reply]

Updating the icon

[edit]

The icon for the {{Used in system}} is generic so it can be confused with any other warnings hardcoded in the /doc, even though the fact that a template is used in system messages is very important. I think it should at least use the same icon as {{High-use}} when set to |risk= to better catch the attention of editors used to seeing a riangular warning for templates that have many transclusions.

Line Module:High-use § L-218 should be changed to:

Line 216: Line 216:
if args['system'] and args['system'] ~= '' then if args['system'] and args['system'] ~= '' then
image = 'Ambox important.svg' image = 'Ambox warning orange.svg'
type_param = 'content' type_param = 'content'
if yesno(nocat or args['nocat']) ~= true and not args.title.isRedirect then if yesno(nocat or args['nocat']) ~= true and not args.title.isRedirect then

FaviFake (talk) 18:33, 11 October 2025 (UTC)[reply]

Example of two templates looking the same in the /doc: {{Clickable button}} FaviFake (talk) 18:53, 11 October 2025 (UTC)[reply]
Please link to the discussion that prompted the use of {{tper}} here. The template is for edit requests that are uncontroversial or supported by consensus. – Jonesey95 (talk) 20:11, 11 October 2025 (UTC)[reply]
I assumed it would be uncontroversial. Why do you oppose the change? FaviFake (talk) 20:14, 11 October 2025 (UTC)[reply]
Why would you assume that? Did you look in the page history to see that the change was made in April 2021 and the image has been stable since that change was discussed? You appear to be proposing to change the image back without discussion. – Jonesey95 (talk) 00:08, 12 October 2025 (UTC)[reply]
And you appear not to be discussing. I asked why you oppose the change. FaviFake (talk) 07:29, 12 October 2025 (UTC)[reply]
I oppose your abuse of the edit request template, which comes with clear instructions. You continue to waste the time of editors, especially those with template editor permissions. – Jonesey95 (talk) 01:40, 13 October 2025 (UTC)[reply]
So you don't oppose the actual change I'm proposing? Seems the template was entirely justified then. FaviFake (talk) 04:16, 13 October 2025 (UTC)[reply]
@Jonesey95 Just know that I will add it back in a few weeks if nobody actually opposes the change. Which hopefully won't happen because it is minor. FaviFake (talk) 17:23, 13 October 2025 (UTC)[reply]
@FaviFake, I concur with @Jonesey95 that edit requests should be implemented for uncontroversial changes, and that design changes like this are potentially controversial (something you should know after having just prompted 40+ editors to spend months debating which color to use for the village pump header...)
You can make a proposal on a template talk page, and if no one responds after a while (particularly if you put a {{Please see}} invite somewhere more prominent), then you'll have silent consensus to add the request (at which point the template editor will serve as the second opinion). But just jumping to the request is short-circuiting the process.
To comment on the actual proposal, I don't have a strong view. There is somewhat of a system for which notices warrant which level of caution, and we should try to adhere to that (and build it out/formalize it) to prevent banner blindness. On the one hand, a template having many transclusions is absolutely a good reason to be significantly more cautious editing it, which argues for a more prominent notice. On the other, there isn't any concrete action that this is cautioning about (e.g. something editors might be tempted to do that this is warning against) and many high-use templates are already TE-protected (and TEs should know that protected templates they edit likely have many transclusions/require care). Sdkbtalk 17:51, 13 October 2025 (UTC)[reply]
@Sdkb I do oftentimes create a discussion first. It seems I have misjudged the "uncontroversiality" of this specific change, but I definitely welcome a discussion based on non-procedural arguments. Here's an instance where it seems the "discussion time" was unnecessary, for example.
Banner blindness is actually the reason I proposed the change in the first place. In the example of {{Clickable button}}'s /doc I gave above, these two mssages look the same:
Despite the first one being significantly more important than the second one. The {{Warning}} template in particular is very frequently used in /docs, especially for higher-risk templates, so I think the templae for "used in system" should at least match the icon of {{High-use}} when set to |risk=
And in general, we try to use a non-default icon for widely used templates. FaviFake (talk) 19:11, 13 October 2025 (UTC)[reply]
We're in an unfortunate arms race, which is exactly how you get a bunch of bloated screaming notices, which is the exact bad outcome banner blindness warns against. I'd much prefer to see less important notices appropriately deemphasized rather than more important ones shouting ever louder (since everyone thinks that their notice is important and thus should shout, so the arms race never ends).
For notices like the second one, there are often better solutions. For instance, have editors considered adjusting the template code so that it produces an error if used in mainspace? That'd solve the problem and allow the notice to be removed (or at least converted to just a normal text part of the documentation). Sdkbtalk 19:23, 13 October 2025 (UTC)[reply]
I agree, but since this is the current state of template documentation banners, I think this template should distinguish itself in the same way that its sister template does, with a triangular warning icon. As long as we use the default icon, banner blindness is bound to happen. FaviFake (talk) 04:14, 14 October 2025 (UTC)[reply]
Sdkb since unfortunately we can't change all the {{warning}} templates placed on documentation pages into {{notice}} all at once, would you support the change from the default icon to the icon used by the same family of templates? For consistency, I think that if this template's icon isn't changed, then the other triangular icons of the High-use template should be reverted back to the default {{warning}} icon, as they basically say the same thing: this template is widely used. But this would create even more binder blindness, which is why I think we should stop using the default icon on just this template. Thoughts? FaviFake (talk) 07:46, 25 October 2025 (UTC)[reply]