Bug #76281 [NEW]: Opcache causes incorrect "undefined variable" errors
From: woody dot gilk at gmail dot com
Operating system: Linux
PHP version: 7.2.5
Package: opcache
Bug Type: Bug
Bug description:Opcache causes incorrect "undefined variable" errors
Description:
------------
% php --version
PHP 7.2.4-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Apr 5 2018
08:53:57) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.4-1+ubuntu16.04.1+deb.sury.org+1, Copyright
(c) 1999-2018, by Zend Technologies
PHP 7.2.5 is not yet available for my distro.
The bug does NOT appear on PHP 7.1.16.
When running the test script (part of a larger class) the following
error always occurs:
E_NOTICE: Undefined variable: user_sub_resource on line 37
For obvious reasons, this is an impossible situation because the
variable is defined and can only be a boolean.
When I disable opcache the problem disappears and everything works
correctly.
Test script:
---------------
$user_sub_resource = in_array($action, array('get_securityquestions',
'get_status', 'get_groupstats'));
$user_id = null;
if ($user_sub_resource && isset($r['user_id'])) { // !! NO ERROR HERE
!!
$user_id = $r['user_id'];
}
else if (isset($r['id'])) {
$user_id = $r['id'];
}
if ($user_sub_resource) { // !! ERROR HAPPENS HERE !!
if ($action === 'get_securityquestions' &&
!$this->isRequestor($r['user_id'])) {
$this->violation('can\'t get another user\'s security
information');
}
return $perms;
}
--
Edit bug report at https://bugs.php.net/bug.php?id=76281&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76281&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76281&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76281&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76281&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76281&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76281&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76281&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76281&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76281&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76281&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76281&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76281&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76281&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76281&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76281&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76281&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76281&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76281&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76281&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76281&r=mysqlcfg
Thread (5 messages)
- woody dot gilk at gmail dot com