Page MenuHomePhabricator

VisualEditor should not show template sandboxes in template search
Closed, ResolvedPublic

Description

For example https://en.wikipedia.org/w/index.php?title=Powell_National_Forest&diff=prev&oldid=1281878617 - adding the sandbox version of a template via VE is almost never useful and seems to be a fairly common error - I fix one or two every few days.

Event Timeline

I think VE should probably add any sort of template/link that the user explicitly enters. That said, perhaps the search should know not to include certain types of pages? (We're using action=query, generator=prefixsearch, targeted to the Template namespace.)

CleanShot 2025-03-25 at 16.58.47@2x.png (1,198×960 px, 162 KB)

Main issue here is detecting those pages in a cross-project way. We'd presumably want to either look for "/sandbox" in the page-title or check the page for the "template sandboxes" category -- both of which would need localization.

One option would of course to be to add a magic word for "don't show this template in search".

And yeah, if you explicitly type the name of the template I'm fine with VE carrying that out, but template search shouldn't find it.

It occurs to me that we already do this for /doc pages if TemplateData is installed on a wiki.

const templateDataMessage = mw.message( 'templatedata-doc-subpage' ),
	templateDataInstalled = templateDataMessage.exists(),
	templateDocPageFragment = '/' + templateDataMessage.text();

// T54448: Filter out matches which end in /doc or as configured on-wiki
if ( templateDataInstalled ) {
	newPages = newPages.filter(
		// Can't use String.endsWith() as that's ES6.
		// page.title.endsWith( templateDocPageFragment )
		( page ) => page.title.slice( -templateDocPageFragment.length ) !== templateDocPageFragment
	);
}

So there's a clear precedent to follow.

matmarex renamed this task from VisualEditor should not let users add sandboxes to VisualEditor should not show template sandboxes in template search.Mar 26 2025, 12:20 PM

Change #1141430 had a related patch set uploaded (by DLynch; author: DLynch):

[mediawiki/extensions/VisualEditor@master] Filter out /sandbox pages from template search results

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

This change will also need to happen in TemplateData for the Template-Discovery-And-Recall project (where it's also not currently ignoring /doc).

We can add the sandbox message to TemplateData, and then use it there and in MWTemplateTitleInputWidget.

One option would of course to be to add a magic word for "don't show this template in search".

I think that could be pretty useful for a bunch of things: these subpages, but also templates that shouldn't be exposed to users for whatever reason. A bit like a hidden category, a hidden template could be an 'internal use only' sort of thing.

Change #1141430 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Filter out /sandbox pages from template search results

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