Page MenuHomePhabricator

VisualEditor template insert doesn't show descriptions for template redirects
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue

This is how I noticed the issue:

  1. Open VisualEditor on English Wikipedia
  2. Type {{ and then tl
  3. Replace tl with template link

What happens?:

Recall that {{tl}} redirects to {{template link}} on English Wikipedia.

On step 2, we don't get a description for {{tl}}:

VisualEditor_template_redirect.png (628×898 px, 39 KB)

On step 3, we do get a description for {{template link}}:

VisualEditor_template_not_redirect.png (628×898 px, 41 KB)

What should have happened instead?:

Both should get descriptions.

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

I tried this in Google Chrome Version 115.0.5790.171 (Official Build) (64-bit), though presumably any browser where VisualEditor works would have this problem.

Especially since it looks like, to figure out what to show when you type {{tl, VisualEditor ends up making the following two API calls:

(At least, that's what happened for me.)

Unfortunately, the returned result (with all titles but Template:tl trimmed out, see API Sandbox) is:

{
    "batchcomplete": true,
    "pages": {
        "66733012": {
            "title": "Template:Tl",
            "notemplatedata": true,
            "params": []
        }
    }
}

That certainly explains why VisualEditor isn't showing the description: it didn't receive one.

However, close examination of the API sandbox, or of the API help at https://www.mediawiki.org/w/api.php?action=help&modules=templatedata, reveals the existence of a redirects parameter; if we set this to true (see API Sandbox), we instead get:

{
    "batchcomplete": true,
    "pages": {
        "1487430": {
            "title": "Template:Template link",
            "description": "This template displays a template name as a link surrounded by braces, thus showing how the template name would be used in code. Its primary use is in instruction and documentation.",
            "params": {
                "1": {
                    "label": "Template name",
                    "description": "Positional parameter: the template name without the namespace prefix “Template:”, which is added automatically",
                    "type": "wiki-template-name",
                    "required": true,
                    "suggested": false,
                    "deprecated": false,
                    "aliases": [],
                    "autovalue": null,
                    "default": null,
                    "suggestedvalues": [],
                    "example": null
                }
            },
            "format": "inline",
            "sets": [],
            "maps": {}
        }
    },
    "redirects": [
        {
            "from": "Template:Tl",
            "to": "Template:Template link"
        }
    ]
}

This time, we got the TemplateData for the actual template, {{template link}}, along with a list of relevant redirects under the redirects key. That's everything needed to display the actual description (and possibly even the redirect target).

I hope that's helpful.

Here are the screenshots again at full size:

VisualEditor_template_redirect.png (628×898 px, 39 KB)

VisualEditor_template_not_redirect.png (628×898 px, 41 KB)

Event Timeline

Thanks for the bug report!

It looks like the code making these requests already supports the redirects parameter, but it only uses it optionally: https://gerrit.wikimedia.org/g/mediawiki/extensions/VisualEditor/+/fffc3514da831f8871df7f930b1f6ee4b740d8fa/modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js#151

And I can't find anywhere that we'd enable the showRedirects option: https://codesearch.wmcloud.org/search/?q=showRedirects

I don't know how that happened, but maybe it can just be changed…