Fix example_addressbook search() reporting zero results despite matches (#9022) - #10264
Merged
Merged
Conversation
…es (roundcube#9022) example_addressbook_backend::search() added matching records to the rcube_result_set via $result->add($record) but never set the result set's count, so search() reported count = 0 and the UI showed no results even when records matched. Set $result->count to the number of matched records. Co-Authored-By: Claude Fable 5 <[email protected]>
MiMoHo
force-pushed
the
pr-example-addressbook-9022
branch
from
July 16, 2026 08:13
560e54c to
c86d65d
Compare
alecpl
pushed a commit
that referenced
this pull request
Jul 18, 2026
…es (#9022) (#10264) example_addressbook_backend::search() added matching records to the rcube_result_set via $result->add($record) but never set the result set's count, so search() reported count = 0 and the UI showed no results even when records matched. Set $result->count to the number of matched records. Co-authored-by: Claude Fable 5 <[email protected]>
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.
Problem
Searching an address book provided by the
example_addressbookplugin returned no results in the UI even when records matched the query. The plugin serves as the reference implementation for custom address book backends, so the bug also misleads plugin authors who copy it.Root cause
In
plugins/example_addressbook/example_addressbook_backend.php,search()(line ~146) adds each matching record to the result set via$result->add($record), butrcube_result_set::add()only appends torecords— it does not updatecount. The result set is constructed with the defaultcount = 0and that value is never updated, so the caller seescount === 0and treats the search as empty, regardless of how many records were actually matched.Fix
Increment
$result->countalongside each$result->add($record)insearch(), mirroring the counting pattern already used in the backend'scount()andget_record()methods.Testing
Added
test_search()inplugins/example_addressbook/tests/ExampleAddressbookTest.php, which searches for a value matching exactly one of the static demo records and asserts bothrecordsandcount. The test fails on unmodified code (countis 0, expected 1) and passes with the fix. The full test file passes (3 tests) and phpstan (level 4) reports no new errors on the changed file.Fixes #9022