Bug #77743 [Com]: Random evaluation
Edit report at https://bugs.php.net/bug.php?id=77743&edit=1
ID: 77743
Comment by: houman dot bakhtiari at groupe-gts dot fr
Reported by: houman dot bakhtiari at groupe-gts dot fr
Summary: Random evaluation
Status: Open
Type: Bug
Package: opcache
Operating System: Debian (test on docker FPM 7.3)
PHP Version: 7.2.16
Block user comment: N
Private report: N
New Comment:
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);
}
}
}
Previous Comments:
------------------------------------------------------------------------
[2019-03-14 17:00:42] 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)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77743&edit=1
Thread (5 messages)