-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Cache fix #986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache fix #986
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 6 out of 23 changed files in this pull request and generated no comments.
Files not reviewed (17)
- composer.json: Language not supported
- scripts/test.php: Language not supported
- scripts/test_standalone.php: Language not supported
- src/Cache/Cache.php: Language not supported
- src/Cache/CacheException.php: Language not supported
- src/Cache/CacheItem.php: Language not supported
- src/MobileDetect.php: Language not supported
- standalone/autoloader.php: Language not supported
- standalone/deps/cache/LICENSE.txt: Language not supported
- standalone/deps/cache/composer.json: Language not supported
- standalone/deps/cache/src/CacheException.php: Language not supported
- standalone/deps/cache/src/CacheItemInterface.php: Language not supported
- standalone/deps/cache/src/CacheItemPoolInterface.php: Language not supported
- standalone/deps/cache/src/InvalidArgumentException.php: Language not supported
- tests/CacheItemTest.php: Language not supported
- tests/CacheTest.php: Language not supported
- tests/MobileDetectWithCacheTest.php: Language not supported
Comments suppressed due to low confidence (3)
docker-compose.yml:7
- [nitpick] The commented out volume mapping may cause confusion; if it is no longer required, consider removing it or adding a clarifying comment on its purpose.
# - ./:/app
standalone/deps/cache/CHANGELOG.md:1
- Removing the CHANGELOG removes historical release context; consider archiving it or linking to maintained release notes to support users in tracking breaking changes.
# Changelog
standalone/deps/cache/README.md:1
- The removal of the README which documented the PSR-6 caching interface might leave users without migration guidance; ensure that alternative PSR-16 documentation or a migration notice is provided elsewhere.
-Caching Interface
|
@ArchBlood @stof fyi |
|
Just my two cents; 1. Key ValidationPSR-16 Requirement:
Fix: Update if (!is_string($key) || $key === '' || !preg_match('/^[A-Za-z0-9_.]{1,64}$/', $key)) {
throw new InvalidArgumentException("Invalid key: '$key'. Must match /^[A-Za-z0-9_.]{1,64}$/");
}2.
|
| Area | Fix Required? | Description |
|---|---|---|
| Key Validation | ✅ | Enforce PSR-compliant key rules |
| TTL Expiry Handling | ✅ | has() must not rely on get() |
| Iterable Key Checks | ✅ | Validate all keys in *Multiple() methods |
| Custom PSR Exception | ✅ | Throw correct PSR exception |
| Cleanup Unused Methods | Remove checkKeyArray() if unused |
Note: Not sure on the use case for why changing methods from
publictoprotectedis needed here.
👍 agree
👍 The docs are kinda ambiguous: I think you are correct, because you code also satisfies: Also
👍 Looks like
👍
👍
That would be clean, but I'm kinda afraid of not interfering with somebody implementing a PSR-16 compatible cache system. Most likely I'll use the alias in code so I can see clearly what exception I'm throwing.
👍
I'm thinking that |
I was just afraid that changing these methods would affect the implementation of the interface itself. 🤔 |
@ArchBlood I checked Btw great comments 🙇 , really made me throw a hard look over the entire cache related code. Will come back today with the code changes. |
I look forward to the changes, and I'm sure that everyone that uses this will appreciate all of the hard work as well! |
your own exception class would be in your own namespace, so there is no interference. |
stof
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to add https://packagist.org/packages/cache/integration-tests in your dev dependencies to use this shared testsuite for PSR-16 (and PSR-6 but this is not relevant here) to ensure your implementation follows the PSR-16 rules properly.
Code review phase 1 addressed
|
fyi: Still wip, even if all tests pass
@stof Thank you, checking this right now after I refactored I think these @Tynael thanks for the review, addressed all |
|
I've also found |
ArchBlood
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PSR-16 specifies:
- Methods like
delete(),clear(), etc., MUST returnbool. You already do this, but just ensure no exceptions are thrown unless it's about an invalid key. - ✅ You're safe as long as
checkKey()is the only method that throws.
Minor Suggestions (Optional)
- Error messages from
checkKey()can optionally match PSR’s less opinionated guidance. PSR only requires an exception for invalid keys; the format enforcement (regex) is yours — valid, but stricter than PSR. checkReturn()is fine but could be simplified within_array(false, $array, true) === false.
You need to remove the scalar type hint Example
|
|
@ArchBlood no way I'm removing scalar types, they are mentioned in the original interface are you using AI-tools to check the changes? |
I ran a check through GitHub on a private action in a HumHub-specific container to identify any issues. I'm in complete agreement if you'd prefer not removing scalar types and relying on using |
Added MobileDetectExceptionCode class (enums not supported by 8.0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 13 out of 29 changed files in this pull request and generated no comments.
Files not reviewed (16)
- composer.json: Language not supported
- scripts/test.php: Language not supported
- scripts/test_standalone.php: Language not supported
- src/Cache/Cache.php: Language not supported
- src/Cache/CacheException.php: Language not supported
- src/Cache/CacheInvalidArgumentException.php: Language not supported
- src/Cache/CacheItem.php: Language not supported
- src/Exception/MobileDetectException.php: Language not supported
- src/Exception/MobileDetectExceptionCode.php: Language not supported
- src/MobileDetect.php: Language not supported
- standalone/autoloader.php: Language not supported
- standalone/deps/cache/LICENSE.txt: Language not supported
- standalone/deps/cache/composer.json: Language not supported
- standalone/deps/cache/src/CacheException.php: Language not supported
- standalone/deps/cache/src/CacheItemInterface.php: Language not supported
- standalone/deps/cache/src/CacheItemPoolInterface.php: Language not supported
Comments suppressed due to low confidence (3)
docker-compose.yml:21
- The change of the coverage output directory from './coverage' to '.coverage' may affect downstream processes; please confirm that all related configurations have been updated.
/bin/sh -c "vendor/bin/phpunit -v -c tests/phpunit.xml --coverage-html .coverage --strict-coverage --stop-on-risky"
.github/workflows/website.yml:49
- Verify that upgrading the upload-pages-artifact action to v3 is fully compatible with your deployment workflow.
uses: actions/upload-pages-artifact@v3
.github/workflows/website.yml:55
- Ensure that the deploy-pages action upgrade to v3 does not require additional configuration changes in the deployment process.
uses: actions/deploy-pages@v3
Potential breaking changes.
Fixing #984, #979, #978
Backstory:
When I implemented cache for MobileDetect class I looked over PSR-6 and PSR-16 and I have combined both implementations and that resulted in ambiguous return values for Cache get or interfaces ambiguity (see #982).
I now looked over current various caching libs implementations in Github and saw that PSR-16 aka
psr/simple-cacheis the way to go.