Skip to content

Re-throw RedisCache::increment errors instead of returning 0#46

Merged
sascha-egerer merged 1 commit into
mainfrom
chore/rediscache-rethrow-on-errors
May 27, 2026
Merged

Re-throw RedisCache::increment errors instead of returning 0#46
sascha-egerer merged 1 commit into
mainfrom
chore/rediscache-rethrow-on-errors

Conversation

@sascha-egerer
Copy link
Copy Markdown
Contributor

increment() previously swallowed every \Throwable from the Predis client and returned 0, which every counter caller interpreted as "no hits this window". The exception now bubbles up to Middleware::process() so the configured Config::failOpen policy applies uniformly across infrastructure errors; an E_USER_WARNING is emitted before the re-throw for diagnostic visibility.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes RedisCache::increment() to stop swallowing Predis exceptions (previously returning 0) and instead emit a diagnostic E_USER_WARNING and re-throw, allowing Middleware::process() to apply the configured Config::failOpen behavior consistently across cache infrastructure failures.

Changes:

  • Update RedisCache::increment() to emit a warning and re-throw the underlying Redis client exception.
  • Update unit tests to assert re-throw behavior and warning emission (including when an error handler throws).
  • Document the behavior change in the changelog for the upcoming release.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/Store/RedisCache.php Re-throws Predis eval() failures after emitting a diagnostic warning; updates method PHPDoc.
tests/Unit/Store/RedisCacheTest.php Adjusts tests to assert exception re-throw + warning behavior.
CHANGELOG.md Notes the behavioral change and how it interacts with Config::failOpen.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Store/RedisCache.php Outdated
Comment thread tests/Unit/Store/RedisCacheTest.php Outdated
increment() previously swallowed every \Throwable from the Predis client
and returned 0, which every counter caller interpreted as "no hits this
window". The exception now bubbles up to Middleware::process() so the
configured Config::failOpen policy applies uniformly across infrastructure
errors; an E_USER_WARNING is emitted before the re-throw for diagnostic
visibility.
@sascha-egerer sascha-egerer force-pushed the chore/rediscache-rethrow-on-errors branch from 444d02f to 8f56959 Compare May 27, 2026 13:24
@sascha-egerer sascha-egerer merged commit 9b17966 into main May 27, 2026
11 checks passed
@sascha-egerer sascha-egerer deleted the chore/rediscache-rethrow-on-errors branch May 27, 2026 15:39
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