Skip to content

Conversation

@yassinedoghri
Copy link
Contributor

@yassinedoghri yassinedoghri commented Nov 23, 2025

Description
I've added the deleteMatching method back in 2021 to delete multiple cache items based on a pattern. At that time, I didn't get the chance to add the method definition to the CacheInterface because it would introduce a breaking change for users.

Being a breaking change, this PR adds the definition by targeting the next minor version branch (4.7).
This would fix any annoying error from static type checkers, like phpstan for example.

Furthermore, I've removed the base implementation from BaseHandler because all handlers have the method implemented anyways.

fixes #7828

@michalsn
Copy link
Member

Thank you. We will need a changelog entry for this, here: https://github.com/codeigniter4/CodeIgniter4/blob/4.7/user_guide_src/source/changelogs/v4.7.0.rst?plain=1#L43

@yassinedoghri
Copy link
Contributor Author

Done, thank you for the review!

@michalsn
Copy link
Member

One tiny request: please move the Cache entry before the Image entry so we can keep everything in alphabetical order. Thanks!

@yassinedoghri
Copy link
Contributor Author

@michalsn Done :)

Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

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

Looks good, thank you.

@michalsn michalsn added 4.7 breaking change Pull requests that may break existing functionalities labels Nov 23, 2025
@paulbalandan paulbalandan changed the title fix(cache): add deleteMatching method definition in CacheInterface feat(cache): add deleteMatching method definition in CacheInterface Nov 24, 2025
@yassinedoghri yassinedoghri force-pushed the fix/cache-interface branch 3 times, most recently from bb38faf to babfc9c Compare November 26, 2025 08:50
@yassinedoghri yassinedoghri force-pushed the fix/cache-interface branch 5 times, most recently from f6ffa71 to 0b549cc Compare November 26, 2025 18:05
@neznaika0
Copy link
Contributor

`{@inheritDoc}` can be deleted.

@yassinedoghri yassinedoghri force-pushed the fix/cache-interface branch 4 times, most recently from 93653d2 to a8ad4f0 Compare November 26, 2025 20:00
@yassinedoghri
Copy link
Contributor Author

yassinedoghri commented Nov 26, 2025

I have added the native missing return types for all CacheInterface methods and updated the handlers accordingly.
👉 Note that I have fixed a bug for Wincache's increment and decrement methods: they returned mixed instead of bool or int.

Also, I took the liberty to remove the false return type on the getMetaData() method which was deprecated. Let me know if you want me to revert this.

I have added notes to the changelogs for both the changes.

Anything else worth changing while we're at it?

Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

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

Nice catch with WincacheHandler. Can you add this under the "Bugs Fixed" section of the changelog?

@yassinedoghri
Copy link
Contributor Author

All done!

One more thing, I found a // FIXME comment in MemcachedHandler's decrement() method:

// FIXME: third parameter isn't other handler actions.
return $this->memcached->decrement($key, $offset, $offset, 60);

The comment says that the third parameter (being the $initial_value) isn't present in other handlers. What does it mean exactly? Should it be?

I'm guessing the fix should be another PR anyways?

@michalsn
Copy link
Member

I don't use this cache, but it seems like MemcachedHandler for increment() and decrement() is... at least inconsistent.

The $initial_value should always be 0, and we should not set the TTL (we should skip this parameter entirely). Besides, we should support Memcache too - just like we do for other methods, not sure why this was skipped here.

Yes, this should go to a different PR.

Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

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

Thank you!

Copy link
Member

@paulbalandan paulbalandan left a comment

Choose a reason for hiding this comment

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

Thanks. I think this should be 2 separate PRs: 1 for the deleteMatching method, the other for the method signature changes.

@yassinedoghri
Copy link
Contributor Author

Thanks. I think this should be 2 separate PRs: 1 for the deleteMatching method, the other for the method signature changes.

Done. Here's the new PR: #9811

I'll wait for this PR to be merged first before rebasing the other one and merging it.

@paulbalandan paulbalandan changed the title feat(cache): add deleteMatching method definition in CacheInterface feat(cache): add deleteMatching method definition in CacheInterface Nov 27, 2025
@paulbalandan paulbalandan merged commit 43bd5bb into codeigniter4:4.7 Nov 27, 2025
50 checks passed
@paulbalandan
Copy link
Member

Thank you, @yassinedoghri

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

Labels

4.7 breaking change Pull requests that may break existing functionalities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants