-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Symfony version(s) affected: >= 3.2 (probably any Version that uses the Cache component >= 3.2)
APCu extension version(s) affected: <= 5.1.9
Description
When the TagAwareAdapter
is used to decorate an ApcuAdapter
, all item retrievals from the cache will miss.
How to reproduce
I created a fork of the current 5.3
branch with a simple unit test to reproduce the problem: https://github.com/ureimers/cache
In the end, all that's needed to reproduce this, is using new TagAwareAdapter(new ApcuAdapter());
.
Possible Solution
The reason seems to be, that the TagAwareAdapter defines its TAGS_PREFIX
constant using a Null Byte prefix and suffix, which the APCu extension (written in C) treats as the end of a string.
Changing Adapter/TagAwareAdapter.php:34
from
public const TAGS_PREFIX = "\0tags\0";
to, e.g.,
public const TAGS_PREFIX = "§tags§";
make the test (and still all others) pass successfully.
...or simply update to APCu > 5.1.9
(see comment below).
Additional context
After writing this and trying to find out, if this was already addressed with the APCu extension, I eventually found this issue: krakjoe/apcu#247. It seems I could've saved me a day of debugging and creating a unit test repository, because @nicolas-grekas already found out about this (possibly, while writing the initial TagAwareAdapter
) in 2017.
But then I realized, that APCu 5.1.9
is still the version that is bundled with Ubuntu 18.04 LTS, whose EOL is April 2023. Its actually used on some of our third party production systems and cannot be updated that easily.
So maybe the question of this issue is more about, if this qualifies for a bug fix in the first place (e.g., changing TAGS_PREFIX
to a string without Null Bytes or implementing a custom TagAwareApcuAdapter
) or if the solution is "don't use a three year old version of an extension". @nicolas-grekas, as you didn't simply change the constant when you found out about this bug in APCu, I guess there's more to it than just personal preference.