Make query cache helpers private#917
Conversation
📝 WalkthroughWalkthroughThree ChangesQuery-cache method privatization and test adaptation
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Tools execution failed with the following error: Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error) Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR narrows the public API surface of
Confidence Score: 5/5Safe to merge — the change is a straightforward visibility reduction backed by a well-structured shared test trait. All three methods remain fully exercised by the existing test suite through the new reflection wrappers. The project targets PHP ≥ 8.4, where ReflectionMethod::invoke() calls private methods without setAccessible(true), so the helpers work correctly. No logic is altered; only method visibility and test call-sites change. No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "Address query cache helper review" | Re-trigger Greptile |
| @@ -9719,7 +9719,7 @@ public function getCacheKeys(string $collectionId, ?string $documentId = null, a | |||
| * @param string|null $namespace | |||
There was a problem hiding this comment.
purgeCachedQueries, getQueryCacheKey, and getQueryCacheField were all previously public. This is a semver-breaking change: any downstream code that calls these methods directly on a Database instance will receive a fatal Call to private method error at runtime after upgrading. As a distributed library (utopia-php/database), this warrants a major-version bump or at minimum a deprecation cycle before removal from the public surface.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Database/Database.php
Line: 9719
Comment:
**Breaking public API change**
`purgeCachedQueries`, `getQueryCacheKey`, and `getQueryCacheField` were all previously `public`. This is a semver-breaking change: any downstream code that calls these methods directly on a `Database` instance will receive a fatal `Call to private method` error at runtime after upgrading. As a distributed library (`utopia-php/database`), this warrants a major-version bump or at minimum a deprecation cycle before removal from the public surface.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/unit/QueryCacheTestHelpers.php`:
- Around line 9-39: The reflection helpers in QueryCacheTestHelpers are invoking
private Database methods without making them accessible, which can fail on PHP
8.0. Update purgeCachedQueries, getQueryCacheKey, and getQueryCacheField to call
setAccessible(true) on each ReflectionMethod before invoke so the private
Database methods can be exercised reliably in tests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e0e87f9b-4217-49bb-bfa4-d431be487741
📒 Files selected for processing (5)
src/Database/Database.phptests/unit/CacheKeyTest.phptests/unit/QueryCacheTest.phptests/unit/QueryCacheTestHelpers.phptests/unit/WithCacheLeaseTest.php
Summary by CodeRabbit