php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81684 Using null coalesce assignment with $GLOBALS["x"] produces opcode error
Submitted: 2021-12-01 11:11 UTC Modified: 2021-12-05 17:37 UTC
From: rh at tfli dot co dot uk Assigned: ilutov (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 8.1.0 OS: Windows 10 (64Bit)
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rh at tfli dot co dot uk
New email:
PHP Version: OS:

 

 [2021-12-01 11:11 UTC] rh at tfli dot co dot uk
Description:
------------
On PHP 8.1.0, likely following https://wiki.php.net/rfc/restrict_globals_usage, then null coalesce assignment no longer works (when used with a key on $GLOBALS).

Test script:
---------------
<?php

$GLOBALS["x"] = $GLOBALS["x"] ?? [];
var_dump($GLOBALS["x"]); // array(0){}
$GLOBALS["y"] ??= []; // Fatal error: Invalid opcode 23/1/0. in /in/Y4146 on line 5
echo "Done."

Expected result:
----------------
The script outputs the first var_dump (as it does presently) and then echoes Done.

Actual result:
--------------
Fatal error: Invalid opcode 23/1/0. in /in/Y4146 on line 5

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-12-01 12:47 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2021-12-01 12:47 UTC] cmb@php.net
Right: <https://3v4l.org/Y4146>.  Happens also with 8.1.0 (which
is not yet available on 3v4l.org).
 [2021-12-01 12:47 UTC] cmb@php.net
-Package: *General Issues +Package: Scripting Engine problem
 [2021-12-04 22:25 UTC] ilutov@php.net
Proposed patch here:
https://github.com/php/php-src/pull/7717
 [2021-12-05 00:39 UTC] ilutov@php.net
-Assigned To: +Assigned To: ilutov
 [2021-12-05 17:37 UTC] ilutov@php.net
-Status: Verified +Status: Closed
 [2021-12-05 17:37 UTC] ilutov@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at
http://www.php.net/downloads.php

Thanks for the report! Should be fixed in the upcoming PHP 8.1.2 release.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC