Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Handle cursor paginator when no items are found #42963

Merged
merged 2 commits into from
Jun 27, 2022
Merged

[8.x] Handle cursor paginator when no items are found #42963

merged 2 commits into from
Jun 27, 2022

Conversation

rodrigopedra
Copy link
Contributor

Closes #42962

As noted by issue #42962, if the user has a link to a next, or previous page from a pagination using cursor pagination, accessing this URL throws an exception when no items are found.

This PR:

  • Modifies AbstractCursorPaginator@previousCursor and AbstractCursorPaginator@nextCursor methods to check if the $items collection is empty, and if so early returning null before trying to build their respective Cursor instances
  • Add a test case that would fail without the this PR's proposed changes

@driesvints driesvints linked an issue Jun 27, 2022 that may be closed by this pull request
@taylorotwell taylorotwell merged commit b266b75 into laravel:8.x Jun 27, 2022
@rodrigopedra rodrigopedra deleted the issue-42962 branch June 27, 2022 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cursor pagination fails if records have been deleted
2 participants