|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-03-14 17:00 UTC] houman dot bakhtiari at groupe-gts dot fr
Description:
------------
Here is a bug coming from OPCACHE (I think because doesn't appears when disabled). Random evaluation of a variable when OPCACHE is activated. At first run I obtain "bool(false) bool(false) bool(false) bool(false)", After some refresh I always obtain "bool(true) bool(true) bool(true) bool(true)". This bug doesn't appear when all the scripts are in the same file. The bug exists on all 7.2.x and 7.3.x.
Test script:
---------------
test.php :
===
<?php
require 'test2.php';
function myRet(){
return 45;
}
$toto = new Toto();
$toto->process1();
-----------------------
test2.php :
===
<?php
class Toto
{
public function process1()
{
$array_error = [];
$keep_products = [1, 2, 3, 4];
foreach ($keep_products as $k => $v)
{
$id_country = myRet();
if ($id_country === false && false)
{
}
var_dump($id_country === false);
}
}
}
---------------------
Dockerfile :
===
FROM php:7.2.0-fpm-alpine
RUN docker-php-ext-install opcache
WORKDIR /var/www
EXPOSE 9000
CMD ["php-fpm"]
Expected result:
----------------
bool(false) bool(false) bool(false) bool(false)
Actual result:
--------------
after fome refresh : bool(true) bool(true) bool(true) bool(true)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 00:00:02 2025 UTC |
the bug also produces with this code : <?php class Toto { public function process1() { $array_error = []; $keep_products = [1, 2, 3, 4]; foreach ($keep_products as $k => $v) { $id_country = myRet(); if ($id_country === false) { if (false){} } //var_dump($id_country);//interesting evaluation to test var_dump($id_country === false); } } }