Page MenuHomePhabricator

VisualEditor should pre-parse subst: wikitext in autovalues while loading templateData
Open, Needs TriagePublic

Description

In TemplateData of a template, some parameters can have a default value containing some wikitext. This wikitext can contain a template substitution to automatically fill the parameter value. This automatic filling has happened when the page is saved.

VisualEditor and Citoid should parse the subst magic word when they load templateData in order the user see the template content instead of the template name : it could be done for example by calling the already available functions to parse the wikitext with only PreSaveTransform done.


Previous title: {{safesubst:Aujourd'hui}} inside templates inside ref tags)

Previous task description:

On frwiki, for some time, VE is creating many incorrect references like in this edit :

<ref>{{Lien web|langue=|auteur1=|titre=Red Star 93|url=https://fr.wikipedia.org/wiki/Red_Star_Football_Club|site=https://www.redstar.fr/|périodique=|date=|consulté le={{safesubst:Aujourd'hui}}}}</ref>

Outside <ref> tags, the {{safesubst:Aujourd'hui}} is automatically replaced by the current date, which should be a correct default value for the "access date" of a citation. Inside <ref> tags, it's not replaced, so the result is a citation that always has an access date set to the current day, which completely defeats its purpose (to know when a human last checked that the citation is still present...).

I checked the configuration (template data) of the template Lien web, and I don't see anything in it that should result in the inclusion of the safesubst :

  • Parameter "consulté le" has an empty autovalue
  • In the Citoid map, "accessDate" is linked to "consulté le"

Could you fix this issue as many articles end up with the wrong information about when sources have been checked ?

Event Timeline

Substitution does not work inside <ref> tags and this is not likely to be fixed soon. (See T4700 from 2005 and associated patches from years ago)

You should fix the template to not require that substitution and maybe use a bot/or anything more appropriate to force the substitution in affected pages

NicoV reopened this task as Open.EditedDec 30 2019, 6:41 PM

@Ammarpad
I'm not requesting that substitution work inside <ref> tags, and as I said in the description, there's nothing in the template description that suggest to add the {{safesubst;...}} : the "autovalue" for the problematic parameter is empty.
One user tried to add the {{safesubst:...}} on September 9th, but it was reverted the day after specifically because it doesn't work in <ref> tags.

The API call for TemplateData on this template also shows "autovalue": "" for the parameter.

So, the template does not ask for this template to be added, it's been added by VE or Citoid on many articles. This problem started a few months ago (I haven't noted when I started to see this problem), but it doesn't seem to be related to the template configuration. Can you tell me why this {{safesubst:...}} is added by VE ?

And also : can't VE do the substitution itself when inserting references ? The fix for this doesn't have to be general (meaning it doesn't have to work when you manually insert a {{safesubst:...}} inside a <ref>

@matmarex Thanks, I think I misread the date of the revert (September 10th was the previous version...)

I think VE/Citoid could take advantage of being able to use properly {{safesubst:...}} and similar constructs inside references by parsing wikitext with onlyPST option before inserting the text (for example, my tool WPCleaner is doing this when it needs to insert text if there's a function in it) : should I open a new task to ask for this feature ? It's not the feature to handle PST inside <ref> tags, and it's probably not very difficult as there's already the API to do this

Pols12 renamed this task from {{safesubst:Aujourd'hui}} inside templates inside ref tags to VisualEditor should pre-parse subst: wikitext while loading templateData.Jan 1 2020, 5:47 PM
Pols12 added a project: TemplateData.
Pols12 updated the task description. (Show Details)

@NicoV I took the liberty of editing your task: I hope I haven’t made any mistake, else, please fix them.

@Pols12 Thanks. I just edited it a bit, mentioning parsing with only PreSaveTransform function that already exists

That could be reasonable… I think there are some caveats to consider:

  • The subst: would be expanded immediately while editing, rather than when the page is saved. For the use case we discussed ("cite web" access date) this probably doesn't matter, but it could make a difference in other cases, e.g. if the autovalue is a user signature or just the exact current time.
  • It would make VE behave differently than other tools using TemplateData, e.g. https://www.mediawiki.org/wiki/Extension:TemplateWizard

Yes, maybe other tools can consider doing this also? (I'm doing it in WPCleaner when inserting text)
@Samwilson : what do you think for TemplateWizard?

(I just had a thought that maybe doing this should be an option in the action=templatedata API.)

(I just had a thought that maybe doing this should be an option in the action=templatedata API.)

Could be an idea, but parsing may require extra information compared to templatedata (like page title)

awight renamed this task from VisualEditor should pre-parse subst: wikitext while loading templateData to VisualEditor should pre-parse subst: wikitext in autovalues while loading templateData.Oct 23 2020, 9:26 AM