Page MenuHomePhabricator

Cargo API should display error if field alias starts with "_"
Closed, ResolvedPublic

Description

A Cargo API URL like the following will work fine:

/w/api.php?action=cargoquery&tables=Countries&fields=_pageName=Country

...but a URL like this will only display blank data:

/w/api.php?action=cargoquery&tables=Countries&fields=_pageName

...and so, for that matter, would a URL like this:

/w/api.php?action=cargoquery&tables=Countries&fields=Population=_population

I looked into this, and it's happening because MediaWiki's API code assumes that any data field whose name starts with a "_" is actually metadata. (See ApiResult::isMetadataKey().)

There may be some kind of hack around this, but I think the best solution is just to display an error message if any of the field aliases (or field values, if no alias was set) start with a "_".

Details

Related Gerrit Patches:
mediawiki/extensions/Cargo : masterCargo API should display error if field alias starts with _
mediawiki/extensions/Cargo : masterResolved field name bug

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFeb 26 2018, 1:14 AM
Yaron_Koren added a comment.EditedFeb 26 2018, 1:31 PM

@rosalieper - I admire your enthusiasm, but please don't take this task; I'm trying to limit the number of micro-tasks that any one person takes, and I think you've already done two.

@Yaron_Koren Sorry then! I will unassigned myself

rosalieper removed rosalieper as the assignee of this task.Feb 27 2018, 9:53 AM
rosalieper added a subscriber: rosalieper.

@Yaron_Koren I am interested to work on this and I have a query that /w/api.php?action=cargoquery&tables=Countries&fields=_pageName=_Country , Is this issue is about of presence of '_' before Country? as that is showing a blank data and If I remove '_' before Country that is working properly! and is that the issue to be fixed?

Works on my local machine.

@sahil505 - great! Although it should only display an error message, not any (bad) data.

Change 415800 had a related patch set uploaded (by Sahil505; owner: Sahil505):
[mediawiki/core@master] (T188221) Cargo API should display error if field alias starts with _

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

Change 415989 had a related patch set uploaded (by Sahil505; owner: Sahil505):
[mediawiki/extensions/Cargo@master] (T188221): Cargo API should display error if field alias starts with _

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

Change 415989 had a related patch set uploaded (by Zoranzoki21; owner: Sahil505):
[mediawiki/extensions/Cargo@master] Cargo API should display error if field alias starts with _

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

Change 416341 had a related patch set uploaded (by Sahil505; owner: Sahil505):
[mediawiki/extensions/Cargo@master] (T188221) Resolved field name bug

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

Change 416341 had a related patch set uploaded (by Zoranzoki21; owner: Sahil505):
[mediawiki/extensions/Cargo@master] Resolved field name bug

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

Change 415800 abandoned by Sahil505:
(T188221) Cargo API should display error if field alias starts with _

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

Change 416341 abandoned by Sahil505:
Resolved field name bug

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

Change 415989 abandoned by Sahil505:
Cargo API should display error if field alias starts with _

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

Yaron_Koren closed this task as Resolved.Mar 9 2018, 6:53 PM
Yaron_Koren claimed this task.

Thank you!