Drop the loop's page parameter when a search runs - #59
Merged
Conversation
Playwright — PHP 8.3 / WP latestDetails
|
The search block's form action is built from the current URL, so the pagination parameter the pagination block wrote is carried into the search. Searching from page 2 asks for page 2 of the matches, and a term with only one page of results renders an empty loop over results that do exist. Remove the loop's page parameter from the action, named as core names it so the parameter the pagination block wrote is the one that gets dropped. The taxonomy filter already resets pagination this way. Reported and first fixed by @samikeijonen in #22, which resets the same parameter on the JS side. Props samikeijonen. Fixes #21 Co-authored-by: Sami Keijonen <1820415+samikeijonen@users.noreply.github.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lj871x28S1DXjoVm7AB4k5
roborourke
force-pushed
the
claude/bug-validation-fixes-07a61k-issue-21
branch
from
September 2, 2026 11:39
6196436 to
ca0ff97
Compare
roborourke
marked this pull request as ready for review
September 2, 2026 11:39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #21.
Reproduced
A loop with a search block and pagination, two posts to a page. On
/search-pagination/?query-5-page=2the form action renders as:Searching "Alpha" from there navigates to
?query-5-page=2&query-5-s=Alpha— page 2 of a two-result search — and the loop renders empty, while?query-5-s=Alphaalone returns Alpha One and Alpha Two. Verified on WordPress 6.8.8 and 7.0.4.Changes
inc/namespace.php:render_block_search()removes the loop's page parameter from the form action, alongside the existing/page/Nstrip. The parameter is named the way core names it (query-{queryId}-page, orquery-pagewith noqueryId) so the parameter the pagination block wrote is the one that gets dropped, andpagefor an inherited query. The taxonomy filter already resets pagination this way.tests/seed.phpadds fixture page 5,/search-pagination/: a paginated loop with a search block, two posts to a page.tests/e2e/search-filter.spec.jssearches from page 2 and asserts the page parameter is gone and the matches render.This overlaps #22, which fixes the same bug by rewriting the JS side. Doing it in the action URL keeps the reset next to the other URL building and covers a native form submit with JS disabled too — either is fine by me, closing the older PR in favour of this one is the author's call.
Verification
The new spec fails on
main(Received string: …?query-5-page=2&query-5-s=Alpha) and passes with the fix. Full suite: 21 passed on WP 6.8.8 and 7.0.4.composer phpcsclean.🤖 Generated with Claude Code
https://claude.ai/code/session_01Lj871x28S1DXjoVm7AB4k5
Generated by Claude Code