Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We return 404 error if result is empty. It's a bit confusing for client applications.
Here is some explanations: http://stackoverflow.com/a/13367198/272927
Comment | File | Size | Author |
---|---|---|---|
#11 | restws-2149553-11.patch | 1.08 KB | Chi |
#3 | restws-2149553-1.patch | 1.61 KB | Chi |
#1 | restws-2149553-0.patch | 953 bytes | Chi |
Comments
Comment #1
Chi CreditAttribution: Chi commentedComment #3
Chi CreditAttribution: Chi commentedComment #4
klausiWe should still return 404 for non existing pages, only an empty result should return 200, correct?
Comment #5
Chi CreditAttribution: Chi commented404 for non existing resources and 200 for empty collections.
Comment #6
klausiYes, and a page that does not exist is a non existing resource?
Comment #7
sepgil CreditAttribution: sepgil commentedSince pages are viewed as resources in REST I would asume that is correct.
Comment #8
Chi CreditAttribution: Chi commentedWhat kind of pages we are talking about. The patch impacts only query resources. For example, if we haven't created any articles
GET node.json?type=article should return empty result set
{"list":[]}
(response code 200 OK).Comment #9
klausiYes, and
GET node.json?type=article&page=999
should return a 404, because page 999 does not exist.
Comment #10
Chi CreditAttribution: Chi commentedDrupal Core always returns the last existing page in such cases.
https://drupal.org/project/project_module?page=999
We might as well fix it in the same manner.
Comment #11
Chi CreditAttribution: Chi commentedThis one returns empty data set only for first page.
Comment #12
klausiThat looks wrong, shouldn't we return the usual structure with the "list" element being an empty array in it?
And this should come with a test case that checks on empty node list, should be easy to add in the existing query test.
Comment #13
Chi CreditAttribution: Chi commentedIn the last patch we return
{"list":[]}
or<list/>
for empty result sets.Is it correct?
Comment #14
klausiYes, that would be correct. Oh, I think I was looking in the wrong function when looking a t the source code.
Anyway, we should not return an empty array, but rather the usual $uris variable with the self, first and last variables in it.