Skip to content

Fix example_addressbook search() reporting zero results despite matches (#9022) - #10264

Merged
alecpl merged 1 commit into
roundcube:masterfrom
MiMoHo:pr-example-addressbook-9022
Jul 18, 2026
Merged

Fix example_addressbook search() reporting zero results despite matches (#9022)#10264
alecpl merged 1 commit into
roundcube:masterfrom
MiMoHo:pr-example-addressbook-9022

Conversation

@MiMoHo

@MiMoHo MiMoHo commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Problem

Searching an address book provided by the example_addressbook plugin 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), but rcube_result_set::add() only appends to records — it does not update count. The result set is constructed with the default count = 0 and that value is never updated, so the caller sees count === 0 and treats the search as empty, regardless of how many records were actually matched.

Fix

Increment $result->count alongside each $result->add($record) in search(), mirroring the counting pattern already used in the backend's count() and get_record() methods.

Testing

Added test_search() in plugins/example_addressbook/tests/ExampleAddressbookTest.php, which searches for a value matching exactly one of the static demo records and asserts both records and count. The test fails on unmodified code (count is 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

…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
MiMoHo force-pushed the pr-example-addressbook-9022 branch from 560e54c to c86d65d Compare July 16, 2026 08:13
@alecpl
alecpl merged commit 1791e06 into roundcube:master Jul 18, 2026
17 checks passed
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]>
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.

example_addressbook search isn't working

2 participants