phpapcu

PHP8 - APCuIterator::__construct(): Regular expressions support is not enabled, please enable PCRE for APCuIterator regex support


I have upgraded our Docker images from PHP7.4 to PHP8 and now I am getting this error on every request:

APCuIterator::__construct(): Regular expressions support is not enabled, please enable PCRE for APCuIterator regex support.

We are using Symfony and it is making the call to new APCuIterator(). To reproduce this in isolation, I enabled apcu for CLI and then just invoked the constructor myself:

$ vim /etc/php/8.0/mods-available/apcu.ini
apc.enable_cli=1


$ php -a
Interactive mode enabled

php > new APCuIterator('whatever');
PHP Fatal error:  APCuIterator::__construct(): Regular expressions support is not enabled, please enable PCRE for APCuIterator regex support. in php shell code on line 1

PCRE is enabled though, preg_match() works without problems.


Disabling APCu seems to fix the problem, but that's not a "solution":

# /etc/php/8.0/mods-available/apcu.ini

# extension=apcu.so  <-- comment this out

I am baffled as there is literally no match of this error message on Google.


Solution

  • Turns out this was a version problem. APCu 5.1.17 which I had installed was failing.

    Upgrading to APCu 5.1.20 fixed it.