Page MenuHomePhabricator

DiscussionTools does not correctly identify titles with some variant differences
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:

64 rvprop:'ids',rvlimit:1,titles:pageName}).then((resp)=>resp.query.pages[0].revisions[0].revid);}CommentController.prototype.getTranscludedFromSource=function(){var 
                                                                             ^^^^^^^^^^^^
Uncaught TypeError: Cannot read properties of undefined (reading '0')
    at https://zh.wikipedia.org/w/load.php?lang=zh-tw&modules=ext.discussionTools.init%7Cjquery%2Coojs-ui-core%7Cjquery.ui&skin=vector&version=1rphf:64:84

According to the intercepted request, var pageName is Wikipedia:申请成为管理人员/申請區.

What should have happened instead?:

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

image.png (131×637 px, 11 KB)

Event Timeline

Esanders subscribed.

The canonical page name of the transclusion is
Wikipedia:申请成为管理人员/申请区
not
Wikipedia:申请成为管理人员/申請區

Note that the last two characters are simplified variants. It looks like Parsoid isn't outputting the canonical title. We can't just use redirects:true as this isn't a traditional redirect, but handled by the language converter.

I just want to spell out all of the steps that lead to this.

In https://zh.wikipedia.org/w/index.php?title=Wikipedia:申请成为管理人员&action=edit, the wikitext is written as:

{{/申請區}}

In Parsoid HTML output, e.g. in https://zh.wikipedia.org/w/index.php?title=Wikipedia:申请成为管理人员&useparsoid=1#提名, the same title is used:

<span about="#mwt69" typeof="mw:Transclusion" id="mwAQk" data-mw='{"parts":[{"template":{"target":{"wt":"/申請區","href":"./Wikipedia:申请成为管理人员/申請區"},"params":{},"i":0}}]}'>

Then the DiscussionTools API https://zh.wikipedia.org/w/api.php?action=discussiontoolspageinfo&format=jsonfm&formatversion=2&uselang=zh&page=Wikipedia%3A申请成为管理人员 also uses the same title:

...
            "h-当前的管理员提名-提名-20240403143700": "Wikipedia:申请成为管理人员/申請區",
...

But if you try to do anything with this title in the API, it does not exist: https://zh.wikipedia.org/w/api.php?action=query&format=jsonfm&formatversion=2&titles=Wikipedia:申请成为管理人员/申請區

{
    "batchcomplete": true,
    "query": {
        "pages": [
            {
                "ns": 4,
                "title": "Wikipedia:申请成为管理人员/申請區",
                "missing": true
            }
        ]
    }
}

If you try to visit https://zh.wikipedia.org/wiki/Wikipedia:申请成为管理人员/申請區, you are redirected to https://zh.wikipedia.org/wiki/Wikipedia:申请成为管理人员/申请区.

So, one of these steps needs to replace the title with the one written in the correct variant. It's not clear to me where this should happen, though.


@Umherirrender's suggestion to add converttitles to the API calls should work: https://zh.wikipedia.org/w/api.php?action=query&format=jsonfm&formatversion=2&titles=Wikipedia:申请成为管理人员/申請區&converttitles

{
    "batchcomplete": true,
    "query": {
        "converted": [
            {
                "from": "Wikipedia:申请成为管理人员/申請區",
                "to": "Wikipedia:申请成为管理人员/申请区"
            }
        ],
        "pages": [
            {
                "pageid": 5902260,
                "ns": 4,
                "title": "Wikipedia:申请成为管理人员/申请区"
            }
        ]
    }
}

But it seems wrong for the previous API calls to return the "wrong" title. Maybe this should be fixed at the start, in the Parsoid output? There has been recently some movement on T53587: Parsoid needs to run findVariantLink or some equivalent thing, which seems related.

Until that happens, adding converttitles seems like a good idea.

I think you can also work around the problem by editing the page on zh.wp, replacing {{/申請區}} with {{/申请区}}.

While some fixes have landed related to T53587, we have zhwiki lang conversion disabled in Parsoid (for perf reasons), and since the findVariantLink code calls Parsoid's converter directly, those fixes are skipped for zhwiki. There are planned changes to add a level of indirection where Parsoid asks core for all language conversion which will then call Parsoid's converters if there is a native converter available. That fix will solve this problem. @cc @cscott @Arlolra