Bug #79025 [NEW]: Assigning superglobals by reference in functions are reset to null
| From: | ssigwart at yahoo dot com | Date: | Tue, 24 Dec 2019 05:19:33 +0000 |
| Subject: | Bug #79025 [NEW]: Assigning superglobals by reference in functions are reset to null | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-224504@lists.php.net to get a copy of this message | ||
From: ssigwart at yahoo dot com
Operating system: Any
PHP version: 7.4.1
Package: *General Issues
Bug Type: Bug
Bug description:Assigning superglobals by reference in functions are reset to null
Description:
------------
When you assign a variable to a superglobal ($_SESSION, $_GET, etc) by
reference within a function, the variable is reset to null once you exit
the function.
Test script:
---------------
$_SESSION['var'] = 1;
function func1()
{
global $ref;
global $nonRef;
$ref = &$_SESSION['var'];
$nonRef = $_SESSION['var'];
}
func1();
var_dump($_SESSION['var']);
var_dump($ref);
var_dump($nonRef);
Expected result:
----------------
int(1)
int(1)
int(1)
Actual result:
--------------
int(1)
NULL
int(1)
--
Edit bug report at https://bugs.php.net/bug.php?id=79025&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79025&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79025&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79025&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79025&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79025&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79025&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79025&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79025&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79025&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79025&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79025&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79025&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79025&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79025&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79025&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79025&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79025&r=mysqlcfg