Page MenuHomePhabricator

API output is broken when orderby parameters are not requested was (API HTML output is broken when the municipality or address fields are not requested)
Closed, ResolvedPublic

Description

Compare
https://tools.wmflabs.org/heritage/api/api.php?action=search&limit=1&format=html&srcountry=ru&props=name|municipality|address
to
https://tools.wmflabs.org/heritage/api/api.php?action=search&limit=1&format=html&srcountry=ru&props=name

In the second case, we get the following stacktrace:

 Notice: Undefined property: stdClass::$municipality in includes/FormatHtml.php on line 41

 Call Stack: 0.0073 666464
 1. {main}() api.php:0 0.0920 1646552 
 2. ApiMain::dispatch() api.php:36 0.1042 1955648 
 3. ApiMonuments->executeModule() includes/ApiMain.php:39 0.1269 2190088 
 4. ApiMonuments->search() includes/ApiMonuments.php:72 0.9110 2388968 
 5. FormatBase->output() includes/ApiMonuments.php:338 0.9900 3876616 
 6. FormatHtml->outputContinue() includes/FormatBase.php:42 

Notice: Undefined property: stdClass::$address in includes/FormatHtml.php on line 41

Call Stack: 0.0073 666464 
1. {main}() api.php:0 0.0920 1646552 
2. ApiMain::dispatch() api.php:36 0.1042 1955648 
3. ApiMonuments->executeModule() includes/ApiMain.php:39 0.1269 2190088 
4. ApiMonuments->search() includes/ApiMonuments.php:72 0.9110 2388968 
5. FormatBase->output() includes/ApiMonuments.php:338 0.9900 3876616 
6. FormatHtml->outputContinue() includes/FormatBase.php:42

See also https://tools.wmflabs.org/heritage/api/api.php?action=search&limit=1&sradm0=ru&props=municipality for an example not tied to the html output format.

Details

Related Gerrit Patches:

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 13 2016, 11:30 PM
JeanFred renamed this task from API HTML output is broken when not the municipality or address fields to API HTML output is broken when the municipality or address fields are not requested.Apr 13 2016, 11:30 PM
JeanFred moved this task from Backlog to API on the Wiki-Loves-Monuments board.Apr 13 2016, 11:56 PM

I think a good solution would be to add an array of required fields for each output format and output an error if that constraint is not meet. The good thing with this solution is that the mechanism could be constructed in the base output class.

The alternative is to have that list earlier in the api and silently inject any fields required for a specific format.

Restricted Application added a subscriber: TerraCodes. · View Herald TranscriptJun 15 2016, 5:40 AM

That sounds similar to T143481.

Vennela0212 removed Vennela0212 as the assignee of this task.Oct 5 2016, 12:51 PM
Vennela0212 added a subscriber: Vennela0212.
Lokal_Profil renamed this task from API HTML output is broken when the municipality or address fields are not requested to API output is broken when orderby parameters are not requested was (API HTML output is broken when the municipality or address fields are not requested).Oct 12 2016, 10:01 AM
Lokal_Profil claimed this task.
Lokal_Profil updated the task description. (Show Details)

Change 315488 had a related patch set uploaded (by Lokal Profil):
Require that orderby parameters are included in requested rows

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

Change 315488 merged by jenkins-bot:
Require that orderby parameters are included in requested rows

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

Mentioned in SAL (#wikimedia-labs) [2016-10-19T20:42:57Z] <JeanFred> Deploy latest from Git master: 213b4a9 (T132644)

JeanFred closed this task as Resolved.Oct 19 2016, 8:43 PM

This appears fixed now − good job @Lokal_Profil :)