Bug #67481 [Com]: Opcache uses wrong file from cache

From: Date: Wed, 10 Sep 2014 06:20:00 +0000
Subject: Bug #67481 [Com]: Opcache uses wrong file from cache
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-187488@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67481&edit=1 ID: 67481 Comment by: spam at rw23 dot de Reported by: Danack at basereality dot com Summary: Opcache uses wrong file from cache Status: Open Type: Bug Package: opcache Operating System: Centos PHP Version: 5.5.13 Block user comment: N Private report: N New Comment: php version is 5.5.16 for me Previous Comments: ------------------------------------------------------------------------ [2014-09-10 06:16:06] spam at rw23 dot de its a common problem and also a deal-breaker when using chrooted enviroments like the php-fpm setup, you can find many complains on the net: https://www.google.com/search?q=php-fpm+chroot+opcache.so by using a config file from a wrong neighbor project, this bug can even break things. this is not happening with APC or xcache, so these work around the problem somehow. ------------------------------------------------------------------------ [2014-08-09 03:59:32] wojjie at gmail dot com Same problem exists if you are in a chroot environment. Consider the example provided by the original author and add chroot to the project directories. ie: /home/project1/ /home/project2/ Now each site's index.php is actually: /web/index.php (project1) /web/index.php (project2) Somehow this also causes a collision in the cache and causes PHP to serve the wrong index.php from cache if you hit project1 first followed by project2 next. ------------------------------------------------------------------------ [2014-06-19 17:43:18] Danack at basereality dot com Made summary not be one word. ------------------------------------------------------------------------ [2014-06-19 16:02:37] Danack at basereality dot com Description: ------------ When the config 'opcache.validate_timestamps' is set to 0 opcache incorrectly resolves relative filenames. If you include a file with require "../src/bootstrap.php"; from two completely different directories then OPcache will serve the same file even though realpath("../src/bootstrap.php"); resolves to completely different directories. This does not happen when opcache.validate_timestamps is set to a non-zero value. It can also be worked around by using require __DIR__ . '/../src/bootstrap.php'; Test script: --------------- File /home/project1/web/index.php ================================= <?php require "../src/bootstrap.php"; ?> File /home/project2/web/index.php ================================= <?php require "../src/bootstrap.php"; ?> File /home/project2/src/bootstrap.php ===================================== <?php echo "I am project2's bootstrap file."; If you go to a webpage served by project1 first, then go to a webpage served by project2, project2 will get be given project1's bootstrap file. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67481&edit=1

« previous php.bugs (#187488) next »