Repository navigation
Fix Find response ranges for paginated and empty results - #237
Merged
Merged
Conversation
Collaborator
|
Thanks for the PR, I was initially concerned about adding in the tests folder when we don't have a structured way of testing or running them as CI jobs. But will add this in for now and change it up later. |
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.
Released under the GNU Affero General Public License (AGPL), version 3.
What does this implement/fix?
Find currently encodes its response Range as
0-<searchtotal>. That reports the estimated total rather than the returned page and makes the end index one too large even for an initial page. For example, ten returned messages produce0-10instead of0-9.Use the backend-provided range start, falling back to the requested start, and calculate the end from the number of returned rows. Omit the optional Range element when no rows are returned. Total remains unchanged.
The Find Range specification defines zero-based inclusive indexes and describes the response range as the entries actually returned.
Related issues
Related to #147, but independent of its folder-ID/Fetch discussion. This PR leaves request parsing, folder mapping, Fetch arguments and advertised protocol versions unchanged.
Validation
Added a self-contained WBXML regression test:
Eight cases fail on unmodified
developatc51d2682d8c0d0f74faed3c23da81dd1cb2f2ec3and pass with this change: initial and single-result pages, nonzero offsets, a partial last page, an empty next page, no matches, missing provider range metadata and an omitted request range.Tested with PHP 8.4 CLI on Debian 13 using mock search/device/backend objects. No real mailbox, SQL connection or production configuration is used. The tests also pass when combined with the separately proposed preview-safety fix. Upstream CI has not run yet.
A related stable-version backport was exercised with Apple Mail on an iPhone, including searching outside a one-week sync window and opening results. That device test was not performed against this development branch; validation of this exact branch is the regression test above.