php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69281 opcache_is_script_cached no longer works
Submitted: 2015-03-23 15:09 UTC Modified: 2015-04-01 20:12 UTC
From: danack@php.net Assigned: dmitry
Status: Closed Package: opcache
PHP Version: 5.6.7 OS: Centos
Private report: No CVE-ID:
 [2015-03-23 15:09 UTC] danack@php.net
Description:
------------
The function opcache_is_script_cached is meant to return true if a script is already cached and present in OPCache. This is failing when running in the fpm-cgi in 5.6.7.


It works when:
* called from the CLI sapi.
* in the fpm-cgi sapi in 5.6.2


Test script:
---------------
<?php

var_dump(opcache_is_script_cached(__FILE__));
var_dump(opcache_is_script_cached(realpath(__FILE__)));

//The current file should always be present, as it is compiled and cached before being run.

Expected result:
----------------
bool(true) bool(true)

Actual result:
--------------
bool(false) bool(false) 

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-24 05:43 UTC] laruence@php.net
I can not reproduce this with php-fpm (5.6 branch)
 [2015-03-27 14:21 UTC] danack@php.net
It's possible I'm doing something dumb, but I've tested this against freshly compiled versions of 5.6.2 and 5.6.7 and there does seem to be different behaviour.

File /etc/php.ini
=================

zend_extension=opcache.so

opcache.validate_timestamps=off
opcache.enable=1
memory_limit=127M


test.php
=========
<?php

var_dump(opcache_is_script_cached(__FILE__));





Configure script
================
./configure  \
                --bindir=/usr/bin \
                --sbindir=/usr/sbin \
                --sysconfdir=/etc \
                --localstatedir=/var \
                --with-config-file-path=/etc \
                --with-config-file-scan-dir=/etc/php.d \
                --disable-cgi \
                --disable-rpath \
                --enable-xmlreader \
                --enable-xmlwriter \
                --enable-apcu \
                --enable-fpm \
                --enable-intl \
                --enable-json \
                --enable-mbregex \
                --enable-mbstring \
                --enable-pcntl \
                --enable-pdo \
                --enable-sockets \
                --enable-sysvsem \
                --enable-sysvshm \
                --enable-zip \
                --with-bz2 \
                --with-curl \
                --with-freetype-dir=/usr/lib \
                --with-gd \
                --with-jpeg-dir=/usr/lib \
                --without-mcrypt \
                --with-png-dir=/usr/lib \
                --enable-fd-setsize=8192 \
                --with-pdo-mysql \
                --with-yaml \
                --with-zlib \
                --without-mhash \
                --with-mysql \
                --with-mysqli=mysqlnd \
                --with-openssl \
                --with-pcre-regex \
                --without-pear \
                --enable-maintainer-zts


I'm using the builtin webserver to test `php -S 127.0.0.1:80` and then `wget -O php5.6.2.test 127.0.0.1/test.php` and the same command with a different output filename for 5.6.7 

I'm still seeing that the file is cached according to 5.6.2 and isn't according to 5.6.7
 [2015-03-27 15:03 UTC] danack@php.net
The bug is in two parts, first the timestamp is only set if the opcache.validate_timestamps is enabled:

http://lxr.php.net/xref/PHP_TRUNK/ext/opcache/ZendAccelerator.c#1449


But then OPCache is assuming that the file is only cached if the timestamp is set to not zero.
http://lxr.php.net/xref/PHP_TRUNK/ext/opcache/ZendAccelerator.c#853
 [2015-04-01 20:12 UTC] stas@php.net
-Assigned To: +Assigned To: dmitry
 [2015-04-02 01:07 UTC] laruence@php.net
Automatic comment on behalf of Danack@basereality.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=86f983bd3ea13def42e36842e03f785d02d40a7f
Log: Fixed bug #69281 (opcache_is_script_cached no longer works)
 [2015-04-02 01:07 UTC] laruence@php.net
-Status: Assigned +Status: Closed
 [2015-04-03 07:29 UTC] tyrael@php.net
Automatic comment on behalf of Danack@basereality.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e0e19a12be4aaaedbb7862a0b257bdc901542f57
Log: Fixed bug #69281 (opcache_is_script_cached no longer works)
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Wed Aug 23 02:01:33 2017 UTC