Problem/Motivation
A listing of this module answers a request for a page past the end with three redirect_* keys instead of the listing, under a 200. That is what the OpenAPI description of every listing endpoint says, and it is the contract a front end is written against.
Eight listing resources do something else. They redirect whenever the result set is empty, the first page included, so a listing that legitimately has no items answers with a redirect to the listing the caller has just asked for. A front end that follows it arrives at the same empty listing and is told to go there again.
The same eight build the destination as $path === NULL ? '' : $this->aliasManager->getAliasByPath($path). On a site that has not named the special page the listing belongs to, the redirect answer therefore says redirect_url: "" - a redirect naming nowhere to go, which no caller can act on and which the description does not allow for.
Both are visible only on a site whose listing is empty or whose special pages are not filled in, which is why they have survived: the sites the resources were written for have neither.
Proposed resolution
- Redirect only when the requested page is past the end - an empty first page is an answer, with an empty
items, atotal_itemsof zero and the same keys as any other page. - Build the destination so that it always names somewhere: the alias of the listing page where the site named one, and the first page of the same listing - the request path without the
pageargument - where it did not. - Functional coverage of both, per source, since the eight are split between an entity query and a Search API index.
Remaining tasks
Everything.
Issue fork myrest-3622923
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
sergeydruua commentedComment #6
sergeydruua commented