Page MenuHomePhabricator

Display action blocks properly in ApiQueryBlocks
Closed, ResolvedPublic2 Estimated Story Points

Description

Following T279556: Introduce infrastructure for making partial blocks against actions, action restriction display could be improved in ApiQueryBlocks.

The API returns the integer value of the restriction:

"restrictions": {
    "actions": [
        1
    ]
}

but could instead return the string, which would probably be more meaningful to a caller:

"restrictions": {
    "actions": [
        "upload"
    ]
}

Event Timeline

Here are the results (with T279556 applied) for a block with a title, namespace and action restriction:

"restrictions": {
    "pages": [
        {
            "id": 2,
            "ns": 0,
            "title": "Foo"
        }
    ],
    "namespaces": [
        2
    ],
    "actions": [
        1
    ]
}

Change 686499 had a related patch set uploaded (by STran; author: STran):

[mediawiki/core@master] Return the action name instead of action id in API response

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

dom_walden added a subscriber: dom_walden.

@STran @Tchanders Moving back into code review. There seems to be a CI test failure.

Change 686499 merged by jenkins-bot:

[mediawiki/core@master] Return the action name instead of action id in API response

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

Example entry in action=query&list=blocks&bkprop=id|user|by|timestamp|expiry|reason|flags|restrictions:

{
    "id": 22989,
    "user": "Drwpb",
    "by": "Dom walden",
    "timestamp": "2021-05-12T07:29:52Z",
    "expiry": "infinity",
    "reason": "",
    "allowusertalk": "",
    "partial": "",
    "restrictions": {
        "actions": [
            "upload",
            "move",
            "create"
        ]
    }
}

(More examples here: https://en.wikipedia.beta.wmflabs.org/w/api.php?action=query&list=blocks&bkprop=id|user|by|timestamp|expiry|reason|flags|restrictions&bklimit=20)

I tested turning off the feature flag and raised T282655, which probably existed before this change.

Otherwise, looks good to me.

Test environments: