Page MenuHomePhabricator

Special:Unusedtemplates filtering
Closed, ResolvedPublic

Description

Hi! I succeed to reduce this special list on wp:fr to 1 559 templates. Not only by removing obsolete templates but using it in the documentation. The problem is that it is normal that some listed templates are unused (sandbox, testcases, substituted templates, preload…). I created a category on wp:fr including all exceptions (903 templates). It will be really helpful if a filtering option using a category is added to all Wikipedias. Many thanks.

Event Timeline

@Framawiki Why did I get subscribed here?

I thought you might be interested, since a similar request was opened on one of your GH projects. I apologize if I made a mistake, don't hesitate to remove yourself from the list.

@Framawiki Ah, I missed that request. Thanks for that.

I think you need to explain better what exactly is required here and why. Is it possible to create a dummy page where these unused templates are used and that'd get them off the list?

@Niharika Hi ! First of all, sorry for answering so late but I’m really not familiar with Phabricator and this is the first time I'm posting a request.
Second, we already use this trick of using templates in a dummy page. The problem is that it cannot be used for most of the remaining templates I put in this category (sandbox, test cases, substituted templates, preload, KML code…). In addition, the advantage of using a category is that contrary to a dummy page or a whitelist it will be dynamic. No need of updating such a page.
Another trick I'm using each time it is possible is to use the template in its own documentation. Thousand of templates have been removed from this list this way.
As a workaround solution and if a category is not suitable, we could request a bot to periodically generate a whitelist from the category I created (and all sub-categories).
As a conclusion: Filtering options in all special lists would really improve all maintenance tasks.
If something is still not clear, do not hesitate to request me more information.
Regards

Thanks for more info, @FDo64. It will be hard to use categories to do this filtration on Special:UnusedTemplates because the query for UnusedTemplates runs on every project. Filtering by category would make it enwiki-specific. :(

However filtering out by category should be fairly easy to do in the bot code for BernsteinBot which generates that report on wiki. Maybe talk to its owner about it?

It would be possible to let the user specify in a form which category to excude. But as far as I know, MW should not implement recursive category querying for performance reasons. In this case, excluding a single category would be unuseful.

@Niharika, @Framawiki,@Louperivois: Hi ! I’m back today with a new idea, probably easiest to implement.
I’m currently working on Special:UnusedCategories and there is a magic word doing the same kind of job I’m requesting:

__EXPECTUNUSEDCATEGORY__

Could we envisage creating the following magic word?

__EXPECTUNUSEDTEMPLATE__

Then, all templates containing this magic word should be filtered in the Special:Unusedtemplates page.
Your thoughts?
Regards

Hi @FDo64, it seems to be a very good solution for this issue.

DannyS712 moved this task from To triage to Maintenance reports on the MediaWiki-Special-pages board.
DannyS712 subscribed.

@Niharika, @Framawiki,@Louperivois: Hi ! I’m back today with a new idea, probably easiest to implement.
I’m currently working on Special:UnusedCategories and there is a magic word doing the same kind of job I’m requesting:

__EXPECTUNUSEDCATEGORY__

Could we envisage creating the following magic word?

__EXPECTUNUSEDTEMPLATE__

Then, all templates containing this magic word should be filtered in the Special:Unusedtemplates page.
Your thoughts?
Regards

Claiming to implement suggested addition of a magic word

Change 557438 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] Add expectunusedtemplate to filter Special:UnusedTemplates

https://gerrit.wikimedia.org/r/557438

I @DannyS712
Do you know when this new magic word will be implemented?
On my side, I am ready to use it. All preparation task have been done.
Regards

I @DannyS712
Do you know when this new magic word will be implemented?
On my side, I am ready to use it. All preparation task have been done.
Regards

Just waiting for the patch to be reviewed

Any reason why this was never reviewed and merged? For what it's worth, I just reviewed it and added my +1, but a +2 is still needed.

Removing task assignee due to inactivity as this open task has been assigned for more than two years. See the email sent to the task assignee on August 22nd, 2022.
Please assign this task to yourself again if you still realistically [plan to] work on this task - it would be welcome!
If this task has been resolved in the meantime, or should not be worked on ("declined"), please update its task status via "Add Action… 🡒 Change Status".
Also see https://www.mediawiki.org/wiki/Bug_management/Assignee_cleanup for tips how to best manage your individual work in Phabricator. Thanks!

I think @DannyS712 has done his part, and what is missing is someone with +2 rights to (rebase and) merge the patch.

@matmarex Hi! May I inconvenience you or someone you recommend with a code review for this little useful enhancement?

@Sophivorus The change looks like a good idea and I'd be happy to merge it, but it needs significant changes to be mergeable into current MediaWiki. Would you like to do that? It shouldn't be a lot of work, but I don't want to do it all myself and then merge it, since that defeats the point of code review.

Change #1064007 had a related patch set uploaded (by Sophivorus; author: Sophivorus):

[mediawiki/core@master] Add __EXPECTUNUSEDTEMPLATE__ magic word to filter Special:UnusedTemplates

https://gerrit.wikimedia.org/r/1064007

@matmarex Hi! After a very long delay, I finally got around and did this. Hopefully you can code-review it?

I wasn't sure how to rebase and continue with the older patch (https://gerrit.wikimedia.org/r/c/mediawiki/core/+/557438) so I started a new one. I hope that's not a problem!

I wasn't sure how to rebase and continue with the older patch (https://gerrit.wikimedia.org/r/c/mediawiki/core/+/557438) so I started a new one. I hope that's not a problem!

No, it's alright!

If you just copy the Change-Id: ... line to your commit message, and push it to Gerrit, it will be uploaded as a new patchset for the changeset with that Change-Id. You don't have to rebase the original one, you can redo it from scratch.

However, when you do that to a changeset owned by someone else, it won't appear in the usual place on your dashboard, the original owner can't unsubscribe from emails about it, and you have to have extra permissions to do it in the first place (Trusted-Contributors), so it's often better to just start a new changeset just like you did.

Change #557438 abandoned by Bartosz Dziewoński:

[mediawiki/core@master] parser: Add `__EXPECTUNUSEDTEMPLATE__` magic word for Special:UnusedTemplates

Reason:

Superseded by https://gerrit.wikimedia.org/r/c/mediawiki/core/+/1064007

https://gerrit.wikimedia.org/r/557438

Change #1064007 merged by jenkins-bot:

[mediawiki/core@master] Add __EXPECTUNUSEDTEMPLATE__ magic word to filter Special:UnusedTemplates

https://gerrit.wikimedia.org/r/1064007

matmarex assigned this task to Sophivorus.

Thanks for fixing up the patch! Please also document the new addition at https://www.mediawiki.org/wiki/Help:Magic_words.

Tech News draft wording, please let me know if this needs changes, or if it can be otherwise improved:

Editors who use the [[Special:Unusedtemplates]] page can now filter out pages which are expected to be there permanently, such as sandboxes, test-cases, and templates that are always substituted. Adding the new magic word __EXPECTUNUSEDTEMPLATE__ to a template page will hide it from the listing. Thanks to Sophivorus and DannyS712 for these improvements. [1]

(Timing-wise: We could wait a week, so that editors can immediately start using it once they learn about it, if you prefer?)

For Tech News, please could someone confirm if the above is accurate and suitable, or suggest any needed tweaks? (I've changed it to use present-tense now). Thanks!

For Tech News, please could someone confirm if the above is accurate and suitable, or suggest any needed tweaks? (I've changed it to use present-tense now). Thanks!

LGTM

"Adding the new magic word EXPECTUNUSEDTEMPLATE to a template page will hide it from the listing." 'to a template page'. Which? The template wikisource itself? The ~/doc page? The talkpage? Which?

"Adding the new magic word __EXPECTUNUSEDTEMPLATE__ to a template page will hide it from the listing." 'to a template page'. Which? The template wikisource itself? The ~/doc page? The talkpage? Which?

To the template itself, e.g. https://en.wikipedia.org/wiki/Template:Welcome, in <noinclude> tags: <noinclude>__EXPECTUNUSEDTEMPLATE__</noinclude>

Or to its documentation page, e.g. https://en.wikipedia.org/wiki/Template:Welcome/doc, in <includeonly> tags: <includeonly>__EXPECTUNUSEDTEMPLATE__</includeonly>

Basically, it should be added similarly to how categories are added to templates.

How is anyone to know that? Your https://en.wikipedia.org/wiki/Template:Welcome and https://en.wikipedia.org/wiki/Template:Welcome/doc do not have __EXPECTUNUSEDTEMPLATE__ so no help there.

The behavior switches documentation for __EXPECTUNUSEDTEMPLATE__ is equally unenlightening.

Document so that those of us without the special secret password to inside knowledge can use __EXPECTUNUSEDTEMPLATE__.

Hi! I had to wait 6 years to have this new magic word!
I just can confirm it works.
Many thanks!

We added the magic word to Template:testcases notice on en.WP yesterday, but when the report updated 22 hours later, pages like https://en.wikipedia.org/wiki/Template:Afd_bottom/testcases were still on the report.

I just tested the <includeonly>__EXPECTUNUSEDTEMPLATE__</includeonly> pattern in my test wiki and it works fine. I then looked at the wikitext at Template:Testcases notice and Template:Afd bottom/testcases and everything looks simple enough and ok. I manually purged the template with a null edit but it still appears in Special:UnusedTemplates. Strange.

We added the magic word to Template:testcases notice on en.WP yesterday, but when the report updated 22 hours later, pages like https://en.wikipedia.org/wiki/Template:Afd_bottom/testcases were still on the report.

https://en.wikipedia.org/w/index.php?title=Template:Afd_bottom/testcases&action=info#Page_properties shows that the change took effect now (it lists __EXPECTUNUSEDTEMPLATE__), so I would guess that reprocessing all of the templates using that template simply took more than 22 hours? It seems a bit long for sure, but not impossibly long. Let's see if the next special page update shows it correctly.