Bug #77310 [Com]: Variable values incorrect when Opcache enabled

From: Date: Mon, 07 Jan 2019 02:44:03 +0000
Subject: Bug #77310 [Com]: Variable values incorrect when Opcache enabled
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218821@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77310&edit=1 ID: 77310 Comment by: syntax53 at gmail dot com Reported by: taylor at laravel dot com Summary: Variable values incorrect when Opcache enabled Status: Open Type: Bug Package: opcache Operating System: Multiple PHP Version: 7.3.0 Block user comment: N Private report: N New Comment: I believe a problem I just ran across is related / same as this. This is with PHP 7.3 nts x64 (I tried 7.3.1RC1 and same problem) on Windows 2016. ---[begin] <?php $data[0][0] = 'zero'; $data[0][1] = 0; $data[1][0] = 'one'; $data[1][1] = 1; $data[2][0] = 'two'; $data[2][1] = 2; function breakit($op,$table,$data_arr,$qual="") { switch ($op) { case "go": $foo[0] = ""; $foo[1] = ""; $bar[0] = ""; $bar[1] = ""; for($i = 0; $i < count($data_arr); $i++) { if ($foo[0] != "") { $foo[0]=$foo[0].","; $foo[1]=$foo[1].","; } if ($bar[0] != "") { $bar[0]=$bar[0].","; $bar[1]=$bar[1].","; } $field = "".$data_arr[$i][0].""; $val = "'".$data_arr[$i][1]."'"; $foo[0] .= $field; $foo[1] .= $val; $bar[0] = $bar[0].$field; $bar[1] = $bar[1].$val; } echo "foo[0]: ".$foo[0]."<br>"; echo "foo[1]: ".$foo[1]."<br>"; echo "bar[0]: ".$bar[0]."<br>"; echo "bar[1]: ".$bar[1]."<br>"; break; } } breakit('go','table',$data); ?> ---[end] output-- foo[0]: foo[1]: bar[0]: zero,one,two bar[1]: '0','1','2' (edited) ... with opcache enabled the string concatenation of "var .= value" produces an empty string. But using "var = var . value" works fine. Disable opcache and output of foo and bar is identical. Previous Comments: ------------------------------------------------------------------------ [2018-12-20 15:13:02] cmb@php.net Can you please check with the fix for that bug[1] applied? Instead of applying the fix yourself, you can also test with PHP 7.3.1RC1[2] (announcement including hashes and signatures will follow shortly). Anyhow, this issue might also be related to bug #76937. [1] <http://git.php.net/?p=php-src.git;a=commit;h=93aabf1533bd3af673bb59cf283e6599ced3ab9a> [2] <http://downloads.php.net/~cmb/> ------------------------------------------------------------------------ [2018-12-20 11:57:17] taylor at laravel dot com Might be duplicate / similar issue as: https://bugs.php.net/bug.php?id=77275 ------------------------------------------------------------------------ [2018-12-17 16:59:26] nikic@php.net Off-topic comment by spam2 at rhsoft dot net deleted. ------------------------------------------------------------------------ [2018-12-17 16:50:43] taylor at laravel dot com We have temporarily worked around this by referencing $this->app within the Closure which is set to the same value that $app was previously. So, Laravel >= 5.7.18 should not be affected by this; however, I am worried the bug could affect other areas of code we haven't discovered yet. ------------------------------------------------------------------------ [2018-12-17 15:08:36] taylor at laravel dot com Wanted to add this has been seen on Ubuntu and Mac. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=77310 -- Edit this bug report at https://bugs.php.net/bug.php?id=77310&edit=1

« previous php.bugs (#218821) next »