php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69297 function_exists strange behavior with OPCache on disabled function
Submitted: 2015-03-25 11:53 UTC Modified: 2015-03-25 13:24 UTC
From: d dot ccigii at gmail dot com Assigned: laruence (profile)
Status: Closed Package: opcache
PHP Version: 5.6.7 OS: GNU/Linux, Centos 6.6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
48 - 30 = ?
Subscribe to this entry?

 
 [2015-03-25 11:53 UTC] d dot ccigii at gmail dot com
Description:
------------
I stumbled upon strange behavior of php function function_exists(), when called on disabled function (in php.ini - disable_function). 

The thing is, that if I provide the function name parameter directly as string, the result is different than when provided as variable. When called first time, result is fine. But when the result is served by the OPCache, results are wrong.

Tested in clean build of PHP 5.6 and 5.7, with shipped OPCache (Zend OPcache v7.0.4-dev). In PHP 5.5, the results are correct.

PHP Build:
./configure --prefix=/usr/local/php/5.6.7-test

PHP config:
disable_functions = posix_getpwuid
date.timezone = Europe/Prague
zend_extension=/usr/local/php/5.6.7-test/lib/php/extensions/no-debug-non-zts-20131226/opcache.so

Test script:
---------------
<?
echo phpversion() . "\n";
$f='posix_getpwuid';
$r1=function_exists('posix_getpwuid');
$r2=function_exists($f);
echo "\n\n";

echo "string: ";
var_dump ($r1);
echo "var.  : ";
var_dump ($r2);

echo "opcache status: ";
var_dump(opcache_get_status()['opcache_enabled']);

Expected result:
----------------
This is the result of the first call, this is how it should be:

# /usr/local/php/php-TEST/bin/php-cgi -c /data/web/php-test/ fce.php

X-Powered-By: PHP/5.6.7
Content-type: text/html; charset=UTF-8

5.6.7

string: bool(false)     # <--- correct result
var.  : bool(false)
opcache status: bool(true)

Actual result:
--------------
Any subsequent call:

# /usr/local/php/php-TEST/bin/php-cgi -c /data/web/php-test/ fce.php

X-Powered-By: PHP/5.6.7
Content-type: text/html; charset=UTF-8

5.6.7

string: bool(true)     # <--- HERE IS THE ERROR
var.  : bool(false)
opcache status: bool(true)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-25 13:24 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2015-03-25 15:51 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d380d1cb1ba48c41682f749692b78a10e91dd070
Log: Fixed Bug #69297 (function_exists strange behavior with OPCache on disabled function)
 [2015-03-25 15:51 UTC] laruence@php.net
-Status: Assigned +Status: Closed
 [2015-03-25 15:51 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e46e9a3d22c22ec567423c25f83a6fd7f9655c52
Log: Fixed Bug #69297 (function_exists strange behavior with OPCache on disabled function)
 [2015-03-30 12:21 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d380d1cb1ba48c41682f749692b78a10e91dd070
Log: Fixed Bug #69297 (function_exists strange behavior with OPCache on disabled function)
 [2016-07-20 11:39 UTC] davey@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e46e9a3d22c22ec567423c25f83a6fd7f9655c52
Log: Fixed Bug #69297 (function_exists strange behavior with OPCache on disabled function)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 14:01:29 2024 UTC