Page MenuHomePhabricator

Watchlist api: Anon flag omitted if false in formatversion=2
Open, Needs TriagePublic

Description

Steps to reproduce:
Visit https://en.wikipedia.org/w/api.php?action=query&list=watchlist&formatversion=2 (assuming a user has edited one of the pages shown)

Expected result:

...
"anon": false,
...

Actual result: If the edit was made by a user, the anon flag is not returned at all

Cause:

ApiQueryWatchlist::extractOutputData
if ( !$recentChangeInfo['rc_user'] ) {
	$vals['anon'] = true;
}

Instead, the value should be set $recentChangeInfo['rc_user'] == 0

Details

Event Timeline

DannyS712 created this task.Dec 5 2019, 1:50 AM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 554662 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] ApiQueryWatchlist: set anon flag as false when relevant instead of omitting

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

DannyS712 updated the task description. (Show Details)Dec 5 2019, 1:57 AM
DannyS712 moved this task from Unsorted to Needs Review on the MediaWiki-API board.
Anomie added a subscriber: Anomie.EditedDec 5 2019, 4:04 PM

That was intentional. Values that are often going to be false are sometimes still omitted to avoid cluttering the results with many "false" values.

DannyS712 edited projects, added Core Platform Team Workboards (Clinic Duty Team); removed Core Platform Team.
DannyS712 moved this task from Inbox to External Code Review Needed on the Core Platform Team Workboards (Clinic Duty Team) board.

Please just place items into the Core Platform Team inbox and allow us to move the tasks around as needed. Thanks!

DannyS712 edited projects, added Core Platform Team Workboards (Clinic Duty Team); removed Core Platform Team.
DannyS712 moved this task from Inbox to External Code Review Needed on the Core Platform Team Workboards (Clinic Duty Team) board.

Please just place items into the Core Platform Team inbox and allow us to move the tasks around as needed. Thanks!

Will do in the future.

That was intentional. Values that are often going to be false are sometimes still omitted to avoid cluttering the results with many "false" values.

I read through https://www.mediawiki.org/wiki/API:JSON_version_2#Changes_to_JSON_output_format and the note that "Where the property is usually false, it's sometimes just bloat to include it." - is it documented anywhere what properties will be returned as false vs omitted?

No, it's a really fuzzy judgement call. Sorry I can't be more helpful on that. :(