Skip to content

fix: invalidate cached SEARCH results on message deletion/move - #52

Merged
ralflang merged 1 commit into
horde:FRAMEWORK_6_0from
jcdelepine:fix/invalidate-cached-SEARCH
Aug 29, 2026
Merged

fix: invalidate cached SEARCH results on message deletion/move#52
ralflang merged 1 commit into
horde:FRAMEWORK_6_0from
jcdelepine:fix/invalidate-cached-SEARCH

Conversation

@jcdelepine

Copy link
Copy Markdown
Contributor

When the backend's 'cache' parameter is enabled, _deleteMsgs() correctly invalidates the FETCH data cache and the message map for a mailbox when messages vanish (VANISHED response after EXPUNGE or MOVE), but never touched the SEARCH result cache (CACHE_SEARCH/ CACHE_SEARCHID metadata). Since that cache's validity is keyed off the mailbox's tracked sync token rather than off actual message-set changes, a MOVE that does not visibly advance the local HIGHESTMODSEQ leaves stale UIDs in the SEARCH cache. A subsequent search() on that mailbox then serves those vanished UIDs, and any FETCH/STORE issued against them silently returns nothing.

When the backend's 'cache' parameter is enabled, _deleteMsgs()
correctly invalidates the FETCH data cache and the message map for
a mailbox when messages vanish (VANISHED response after EXPUNGE or
MOVE), but never touched the SEARCH result cache (CACHE_SEARCH/
CACHE_SEARCHID metadata). Since that cache's validity is keyed off
the mailbox's tracked sync token rather than off actual message-set
changes, a MOVE that does not visibly advance the local
HIGHESTMODSEQ leaves stale UIDs in the SEARCH cache. A subsequent
search() on that mailbox then serves those vanished UIDs, and any
FETCH/STORE issued against them silently returns nothing.
@what-the-diff

what-the-diff Bot commented Aug 28, 2026

Copy link
Copy Markdown

PR Summary

  • Enhanced Messaging Experience
    The addition of new procedures will aid in keeping search results up-to-date. When messages are removed or relocated, the program will now remove old, irrelevant search results, thus maintaining the accuracy and relevancy of subsequent searches.

@ralflang

Copy link
Copy Markdown
Member

@jcdelepine Thank you! I will add a unit test to this after merge. I will also add a guard test to #51 but it doesn't cache search results yet so cannot have the same bug (until that feature is added).

@ralflang
ralflang merged commit 41f9bf2 into horde:FRAMEWORK_6_0 Aug 29, 2026
1 check passed
ralflang added a commit that referenced this pull request Aug 29, 2026
Release version 3.1.0

test: Add test coverage for #52 search cache invalidation bug
chore(metadata) add dependency on horde/sasl and bump horde/socket_client dependency to 3.1
style: php-cs-fixer
feat: IMAP4rev2 implementation on src/ PSR-4 codebase
fix: invalidate cached SEARCH results on message deletion/move
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.

2 participants