Page MenuHomePhabricator

API edit on page with non-resolvable redirect and redirect=1 creates page with invalid title
Closed, ResolvedPublic

Description

steps to reproduce:

  1. Have a page with a non-resolvable (interwiki) redirect (to a namespace different from 0): https://de.wikipedia.beta.wmflabs.org/wiki/Benutzer:Hgzh/a
  2. try to edit this page using the API and the redirect=1 parameter https://de.wikipedia.beta.wmflabs.org/w/api.php?action=edit&format=json&title=Benutzer%3AHgzh%2Fa&appendtext=Test&redirect=1&token=

expected behaviour:

  • some kind of error message

observed behaviour:

  • a new page is created
  • as this new page contains the namespace prefix in its title, it is only accessable via curid
    • every ui action refers to the actual talk page (links, protect/delete etc.) instead of the previously created page as they seem to rely on the page_title
    • the new page can only be deleted using the API with curid

API query:
/w/api.php?action=edit&format=json&title=Benutzer%3AHgzh%2Fa&appendtext=Test&redirect=1&token=

API response:

{
    "redirects": [
        {
            "from": "Benutzer:Hgzh/a",
            "to": "meta:User talk:Hgzh"
        }
    ],
    "edit": {
        "new": "",
        "result": "Success",
        "pageid": 4809,
        "title": "meta:User talk:Hgzh",
        "contentmodel": "wikitext",
        "oldrevid": 0,
        "newrevid": 25355,
        "newtimestamp": "2019-11-28T15:43:19Z"
    }
}

Details

Related Gerrit Patches:

Event Timeline

hgzh created this task.Nov 28 2019, 4:11 PM
Restricted Application added a project: Core Platform Team. · View Herald TranscriptNov 28 2019, 4:11 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

After resolving the redirect in ApiEditPage there is no check for Title::isExternal or Title::canExist (to check for Special or Media namespace redirect targets)

Needs some new apierror texts where I am unsure how to name it

Anomie claimed this task.Dec 2 2019, 2:37 PM

You probably shouldn't proclaim that on a public task.

Change 554084 had a related patch set uploaded (by Anomie; owner: Anomie):
[mediawiki/core@master] ApiEditPage: Test for bad redirect targets

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

WDoranWMF triaged this task as High priority.Dec 4 2019, 7:19 PM

Change 554084 merged by jenkins-bot:
[mediawiki/core@master] ApiEditPage: Test for bad redirect targets

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

Change 554885 had a related patch set uploaded (by Anomie; owner: Anomie):
[mediawiki/core@wmf/1.35.0-wmf.5] ApiEditPage: Test for bad redirect targets

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

Change 554886 had a related patch set uploaded (by Anomie; owner: Anomie):
[mediawiki/core@wmf/1.35.0-wmf.8] ApiEditPage: Test for bad redirect targets

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

Change 554885 merged by jenkins-bot:
[mediawiki/core@wmf/1.35.0-wmf.5] ApiEditPage: Test for bad redirect targets

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

Change 554886 merged by jenkins-bot:
[mediawiki/core@wmf/1.35.0-wmf.8] ApiEditPage: Test for bad redirect targets

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

Mentioned in SAL (#wikimedia-operations) [2019-12-05T15:17:31Z] <anomie@deploy1001> Started scap: Backporting fix for T239428

Mentioned in SAL (#wikimedia-operations) [2019-12-05T15:50:51Z] <anomie@deploy1001> Finished scap: Backporting fix for T239428 (duration: 33m 20s)

Anomie closed this task as Resolved.Dec 5 2019, 3:58 PM

Change 554900 had a related patch set uploaded (by SBassett; owner: Anomie):
[mediawiki/core@REL1_34] ApiEditPage: Test for bad redirect targets

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

Change 554900 merged by jenkins-bot:
[mediawiki/core@REL1_34] ApiEditPage: Test for bad redirect targets

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

Change 556284 had a related patch set uploaded (by SBassett; owner: Anomie):
[mediawiki/core@REL1_33] ApiEditPage: Test for bad redirect targets

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

Change 556286 had a related patch set uploaded (by SBassett; owner: Anomie):
[mediawiki/core@REL1_32] ApiEditPage: Test for bad redirect targets

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

Change 556287 had a related patch set uploaded (by SBassett; owner: Anomie):
[mediawiki/core@REL1_31] ApiEditPage: Test for bad redirect targets

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

Change 556287 merged by jenkins-bot:
[mediawiki/core@REL1_31] ApiEditPage: Test for bad redirect targets

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

Change 556286 merged by jenkins-bot:
[mediawiki/core@REL1_32] ApiEditPage: Test for bad redirect targets

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

Change 556284 merged by jenkins-bot:
[mediawiki/core@REL1_33] ApiEditPage: Test for bad redirect targets

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