Page MenuHomePhabricator

API returns incorrect/stale blockinfo for user
Closed, ResolvedPublic

Description

I'm having a problem with the API on bgwiki, where it returns stale blockinfo property for a user whose block has already expired:

https://bg.wikipedia.org/w/api.php?action=query&format=json&list=users&usprop=blockinfo&ususers=Pankoantchev
{
    "batchcomplete": "",
    "query": {
        "users": [
            {
                "userid": 79518,
                "name": "Pankoantchev",
                "blockid": 444747,
                "blockedby": "PSS 9",
                "blockedbyid": 209881,
                "blockedtimestamp": "2018-10-13T16:38:24Z",
                "blockreason": "[[:m:Bot|Bot]]: AI identified [[:m:Wikipedia vandalism|vandalism]]. Disagree? Write to: admin-requests@wikimedia.bg",
                "blockexpiry": "20181014003824"
            }
        ]
    }
}

As blockexpiry shows, the block has expired at 2018-10-14 00:38:24. Wikipedia's UI and Special:BlockList correctly show no active blocks on this user. But the API still returns block data, almost 9 hours later.

For comparison, here's a multi-user query with an additional correctly unexpired (infinity) block and a correctly expired one:

https://bg.wikipedia.org/w/api.php?action=query&format=json&list=users&usprop=blockinfo&ususers=Pankoantchev%7C%D0%98%D1%81%D1%82%D0%B8%D0%BD%D1%81%D0%BA%D0%B8%20%D0%91%D1%8A%D0%BB%D0%B3%D0%B0%D1%80%D0%B8%D0%BD%7CJtyniiii
{
    "batchcomplete": "",
    "query": {
        "users": [
            {
                "userid": 79518,
                "name": "Pankoantchev",
                "blockid": 444747,
                "blockedby": "PSS 9",
                "blockedbyid": 209881,
                "blockedtimestamp": "2018-10-13T16:38:24Z",
                "blockreason": "[[:m:Bot|Bot]]: AI identified [[:m:Wikipedia vandalism|vandalism]]. Disagree? Write to: admin-requests@wikimedia.bg",
                "blockexpiry": "20181014003824"
            },
            {
                "userid": 241796,
                "name": "\u0418\u0441\u0442\u0438\u043d\u0441\u043a\u0438 \u0411\u044a\u043b\u0433\u0430\u0440\u0438\u043d",
                "blockid": 444749,
                "blockedby": "PSS 9",
                "blockedbyid": 209881,
                "blockedtimestamp": "2018-10-14T00:28:13Z",
                "blockreason": "[[:m:Bot|Bot]]: AI identified [[:m:Wikipedia vandalism|vandalism]]. Disagree? Write to: admin-requests@wikimedia.bg",
                "blockexpiry": "infinity"
            },
            {
                "userid": 241022,
                "name": "Jtyniiii"
            }
        ]
    }
}

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 14 2018, 9:14 AM
kerberizer updated the task description. (Show Details)Oct 14 2018, 9:18 AM
kerberizer closed this task as Resolved.Oct 14 2018, 10:16 AM
kerberizer claimed this task.

In the meantime, the problem went away.

{
    "batchcomplete": "",
    "query": {
        "users": [
            {
                "userid": 79518,
                "name": "Pankoantchev"
            }
        ]
    }
}
Aklapper changed the task status from Resolved to Declined.Oct 14 2018, 3:48 PM

Closing as declined as it cannot be reproduced and no code change was identified.

Closing as declined as it cannot be reproduced and no code change was identified.

Fair enough. I'll reopen if I face the problem ever again. My best guess is some caching issue, indeed (though not client-side—I did check with curl from different networks). Thanks!

Anomie reopened this task as Open.Oct 15 2018, 3:24 PM
Anomie moved this task from Unsorted to Needs Review on the MediaWiki-API board.
Anomie added a subscriber: Anomie.

Most likely the problem is that ApiQueryBase::showHiddenUsersAddBlockInfo() doesn't filter out expired blocks. The instance reported here was "fixed" by a run of Block::purgeExpired() when a new block was inserted. You should be able to reproduce on a quiet wiki by setting a block for a short time, letting it expire, and then issuing the API query before anyone makes another block (of any user).

Change 467403 had a related patch set uploaded (by Anomie; owner: Anomie):
[mediawiki/core@master] API: Ignore expired blocks in ApiQueryBase::showHiddenUsersAddBlockInfo()

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

Change 467403 merged by jenkins-bot:
[mediawiki/core@master] API: Ignore expired blocks in ApiQueryBase::showHiddenUsersAddBlockInfo()

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

Anomie closed this task as Resolved.Oct 16 2018, 2:44 PM
Aklapper removed a subscriber: Anomie.Fri, Oct 16, 5:38 PM