Opcache "old scripts" not removed with opcache_reset()... a problem with some deployment tools. How to solve?

93 Views Asked by At

I'm using a PHP deployment tool which creates multiple "release" directories, with a current symlink pointing to the active (latest) release:

releases/
   /1
   /2
current -> releases/2

OPcache seems to work fine with just one release. I'm using a preload script from symfony framework:

opcache.preload = /var/www/vhosts/myproject/httpdocs/current/config/preload.php

The problem begin after the second release. In fact using opcache_get_status() I can see that all files from the previous release 1 are still present under "scripts" (despite calling opcache_reset() using curl):

["scripts"]=>
array(1542) {
  [0]=>
  string(72) "/var/www/vhosts/myproject/httpdocs/releases/1/vendor/autoload.php"
  [1]=>
  string(72) "/var/www/vhosts/myproject/httpdocs/releases/2/vendor/autoload.php"

And this is causing the following problem:

AH01071: Got error 'PHP message: PHP Fatal error: Cannot redeclare composerRequiree7dcbbd7b36b37e14629ddf6c0ff22ac() (previously declared in /var/www/vhosts/myproject/httpdocs/releases/1/vendor/composer/autoload_real.php:73) in /var/www/vhosts/myproject/httpdocs/releases/2/vendor/composer/autoload_real.php on line 73'

Removing the preload options solve the problem. But I'd like to understand why it's working this way and how to solve the issue leaving the preload enable.

0

There are 0 best solutions below