Page MenuHomePhabricator

Template transclusion done "behind the scenes" when saving a user .js page
Open, LowPublic

Description

If a user .js page (such as User:Foo/monobook.js) contains something that looks like template transclusion syntax, it is apparently parsed as such behind the scenes when the page is saved. The transcluded template is never actually shown to the user, since such pages are shown as raw wikitext, but if the template contains any category links, the .js page gets placed in those categories (although no categories are shown on the page itself) and is listed on Special:Whatlinkshere as transclusing the template.

Fixing this properly may be somewhat tricky, since the fact that wikilinks (including category links) and {{subst:...}} are parsed even on user .js pages is generally considered a desirable feature. (The former is used for keeping track of which user .js pages include which scripts, while the latter is used for including standard boilerplate code.) Ideally, the pages should probably go through the pre-save transform (for "subst:") and get parsed for wikilinks, but not for (non-subst) transclusions.

As a workaround, any occurrences of "{{" in user JavaScript may be mangled (for example as "{"+"{") or the entire script (or just the affected parts) may be wrapped in commented-out <nowiki> tags. However, using <nowiki> also disables subst: and link tracking.

Example pages:

See also

Details

Reference
bz8761

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 9:31 PM
bzimport set Reference to bz8761.
bzimport added a subscriber: Unknown Object (MLST).

ais523 wrote:

Note that most WMF wikis, at least, use templates for the 'owner' of a user subpage
to request its deletion. Trying to place a {{db-user}} template on a .js subpage of
my own (on the English Wikipedia), I found that the category didn't appear and the
page wasn't in [[CAT:CSD]] (but other users reported that the category did appear
when they tried it, so it's possible that this is an intermittent bug). So having
categories in templates appear on .js pages is a desirable feature sometimes, but not
always, and its operation appears to be intermittent at the moment.

(In reply to comment #1)

Note that most WMF wikis, at least, use templates for the 'owner' of a user
subpage to request its deletion. Trying to place a {{db-user}} template on a .js subpage of my own (on the English Wikipedia), I found that the category didn't appear and the page wasn't in CAT:CSD (but other users reported that the category did appear when they tried it

FWI: This was my case: after I added {{delete}} to my [[JS]] and [[CSS]] pages, I noticed the page was added to the [[Category:Speedy deletion]], but the link to that category was not displayed in the footer of the pages (making me think I did something wrong, until I looked at the category itself)

Is this problem related to T19525: css and .js pages should not store entries in Categorylinks table/Templatelinks table?

EN.WP.ST47 wrote:

This problem may be a duplicate of bug 8449.

(In reply to Dan Collins from comment #3)

This problem may be a duplicate of bug 8449.

Yeah, sounds like. Anybody eles agreeing that this is a dup?

I don't think so. I think that problem is fixed, because nowadays templates are not expanded in any way that would increase the size of JS and CSS pages.

(In reply to Andre Klapper from comment #4)

(In reply to Dan Collins from comment #3)

This problem may be a duplicate of bug 8449.

Yeah, sounds like. Anybody eles agreeing that this is a dup?

Yes.

  • This bug has been marked as a duplicate of bug 8449 ***

This is not a duplicate. See T10761#129833.

IMO, bug 8449 was never completely fixed, and this is just another symptom of it.

He7d3r set Security to None.

This is still a problem. Examples:

In Special:WantedTemplates on en.WP, non-templates like Template:' + 'subst:afd‏‎ and Template:" + "oldafdfull" + "‏‎ are listed because those strings appear within curly braces in .js files in User space. Those pages are also listed in "What links here" for those template names, showing as transclusions.

Even stranger, if you put {{accessdate}} in a comment in your common.js file, then go to Special:WhatLinksHere/Template:accessdate you will see your common.js file listed as having a transclusion.

None of this makes any sense, and it clutters up the transclusion lists and reports. Maybe .js files should be ignored by whatever generates the "What links here" list.

This may be related to, or the same as, T18683.

(Duplicating comment at T18683 which seems to be a duplicate task.)

I got used to editing some JS and seeing in the bottom something like:

Templates used on this page:

Шаблон:$1 (edit)
Шаблон:$2 (edit)
Шаблон:·/•/* (edit)

It also clutters "what links here" and other special pages.

I understand after reading T34858 that somebody sees parsing JS/CSS for database tables as feature (e.g., helping in categorization and substing), but what use do bogus template transclusions have? What are they helpful for?