Bug #76284 [Com]: auto_globals_jit doesn't detect all types of superglobal use

From: Date: Thu, 03 May 2018 20:04:22 +0000
Subject: Bug #76284 [Com]: auto_globals_jit doesn't detect all types of superglobal use
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215045@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76284&edit=1 ID: 76284 Comment by: jocrutrisi at ibsats dot com Reported by: jocrutrisi at ibsats dot com Summary: auto_globals_jit doesn't detect all types of superglobal use Status: Feedback Type: Bug Package: Scripting Engine problem Operating System: Linux PHP Version: 7.2.5 Block user comment: N Private report: N New Comment: Hello, the samples I posted above are sufficient to reproduce the problems for me. I just enable auto_globals_jit, make sure error reporting (and optionally error display) are on, and then: <?php $foo = $_ENV; ?> This will produce: <br /> <b>Notice</b>: Undefined variable: _ENV in <b>[...][...]</b> on line <b>2</b><br /> If you can't reproduce this, we might need to narrow down the situation. I only have access to 7.2.4 right now, BTW, but this wasn't available in the drop-down with versions, so I had to specify 7.2.5, seeing as the list of fixes contains nothing relevant. Previous Comments: ------------------------------------------------------------------------ [2018-04-29 04:59:50] requinix@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. Works for me, and that exact code you posted won't do the job anyways. The repro script has to be precise, not some summarized version of your tests. ------------------------------------------------------------------------ [2018-04-28 22:38:29] jocrutrisi at ibsats dot com Description: ------------ I was unexpectedly bit by "$_ENV undefined" notice when using auto_globals_jit. Apparently PHP is very specific about what is considered a superglobal use and what isn't. See examples below. Test script: --------------- // This is considered $_ENV use. $foo = $_ENV['foo']; // This is considered $_ENV use. foreach ($_ENV as $k => $v); // BUG: This is NOT considered $_ENV use (so I get a notice here that $_ENV is undefined) $foo = $_ENV; // BUG: Another example of the same problem (I get a notice $_ENV is undefined) function foo() { return ['env' => $_ENV]; } foo(); Expected result: ---------------- I expect JIT should work transparently. Any mention of $_ENV must cause $_ENV to get defined as if it always was. The exceptions are rather odd, it's unclear why detection of use is not fully comprehensive. Actual result: -------------- Notice of undefined $_ENV. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76284&edit=1

« previous php.bugs (#215045) next »