Page MenuHomePhabricator

Better handling for blank aliases in Cargo queries
Closed, ResolvedPublic


In the Cargo extension, there can be cases where people want values to be displayed in query results but without the corresponding field name. So instead of:

Peru (Capital: Lima, Population: 30,000,000)

...they might want to just display:

Peru (Lima, 30,000,000)

The ideal way to do this would be by setting a blank alias in the query - so the call might look like:


(The _pageName field doesn't need an alias for formats like "list", "ol" and "ul", because it is displayed without a field name anyway.)

However, there are two problems with this currently:

  1. Cargo uses the MediaWiki database API to do its queries, and that API uses aliases as array keys - which means that, internally, you can't have blank as an alias for more than one field.
  2. The display of query results for the list-type formats ("list", "ol" and "ul") currently does not have special handling for blank values - so even with just one blank alias, results would show up as "Peru(: Lima)" instead of "Peru (Lima)".

For the first issue, I think the best approach is to have a hidden "internal alias" for each blank alias - if an alias is blank, represent it instead as something like "blank value X", where X is a different number for each blank alias. (Hopefullly, no one will actually want to display their field as "blank value 2" or something.) Then, it should get mapped back to blank before being displayed.

Note that, in Cargo, queries, and display of query results, can happen in many different places in the code - hopefully the mapping can be done only once, or at least in as few places as possible.

The second issue seems more straightforward to fix.


Related Gerrit Patches:
mediawiki/extensions/Cargo : masterChanged handling of blank aliases in Cargo queries

Event Timeline

Yaron_Koren raised the priority of this task from to Needs Triage.
Yaron_Koren updated the task description. (Show Details)
Yaron_Koren added a subscriber: Yaron_Koren.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 2 2015, 1:55 AM
Rits added a subscriber: Rits.Mar 4 2015, 9:22 PM

Change 195036 had a related patch set uploaded (by Namit):
Changed handling of blank aliases in Cargo queries

Change 195036 merged by Yaron Koren:
Changed handling of blank aliases in Cargo queries

Yaron_Koren closed this task as Resolved.Mar 12 2015, 7:01 PM
Yaron_Koren set Security to None.
Bhagyagh removed a subscriber: Bhagyagh.Mar 26 2015, 5:21 PM