Re-throw RedisCache::increment errors instead of returning 0#46
Merged
Conversation
Contributor
There was a problem hiding this comment.
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.
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.
444d02f to
8f56959
Compare
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.
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.