Skip to content

fix(files): classify newly scanned cache entries correctly - #66526

Open
joshtrichards wants to merge 4 commits into
masterfrom
jtr/fix-ScannerNewEntries
Open

joshtrichards wants to merge 4 commits into
masterfrom
jtr/fix-ScannerNewEntries

Conversation

@joshtrichards

@joshtrichards joshtrichards commented Nov 11, 2026 •

Copy link
Copy Markdown
Member
  • Resolves: #(hard to say without an extensive audit)

Summary

  • Compare the file ID against Scanner::FILE_ID_NOT_IN_CACHE so new entries dispatch NodeAddedToCache instead of FileCacheUpdated.
  • Replace the file-ID -1 sentinel with the named constant Scanner::FILE_ID_NOT_IN_CACHE.
  • Add regression coverage for new and updated entries.

Noticed while looking at the difference between CacheEntryInsertedEvent and NodeAddedToCache events.

Context:

TODO

  • Backport?

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

The scanner uses -1 as the sentinel for entries without an existing
cache ID. Because -1 is truthy in PHP, the current check dispatches FileCacheUpdated instead of NodeAddedToCache for new entries.

Compare the ID explicitly against -1 so new and updated entries
dispatch the appropriate events and are counted correctly.

Signed-off-by: Josh <josh.t.richards@gmail.com>
Verify that scanning dispatches NodeAddedToCache for a new entry
and FileCacheUpdated for an existing changed entry.

Assisted-by: Copilot:gpt-6.1-terra

Signed-off-by: Josh <josh.t.richards@gmail.com>
Define FILE_ID_NOT_IN_CACHE and use it for the default, assignment, and insert/update checks in the cache scanner.

Signed-off-by: Josh <josh.t.richards@gmail.com>
Use Scanner::FILE_ID_NOT_IN_CACHE instead of the -1 literal when distinguishing new cache entries from existing ones.

Also swap the conditional logic ordering for clarity.

Signed-off-by: Josh <josh.t.richards@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants