php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77678 7.2.15 Empty array key recognized as string
Submitted: 2019-02-28 09:28 UTC Modified: 2020-01-20 17:14 UTC
From: dantaeusb at live dot com Assigned:
Status: Wont fix Package: Xdebug
PHP Version: 7.2.15 OS: RHEL, Ubuntu
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dantaeusb at live dot com
New email:
PHP Version: OS:

 

 [2019-02-28 09:28 UTC] dantaeusb at live dot com
Description:
------------
Under some circumstances, the following code (shortened, see link below for more info):

$selects = array();
foreach (array_keys($this->getAttributesByTable()) as $table) {
  echo gettype($selects);
  var_dump($selects);
  echo gettype($selects[$eavType]);

  $selects[$eavType][] = $this->_addLoadAttributesSelectFields($select, $table, $eavType);
}

Got executed with the following result:

array
.../Abstract.php:992: array (size=0)  empty
string

( ! ) Fatal error: Uncaught Error: [] operator not supported for strings in .../Abstract.php on line 995

As you can see, it seems like for some reason type of value in an empty array got recognized like a string. I checked a lot of options and asked for community help but as far nobody could answer why is that happening, so I decided to make a bug report.

Unfortunately, this happens very rarely under some unknown circumstances, so I can't make test script or make a gdb backtrace using CLI. If you can help me and explain how to grab some more useful data about scope or execution environment

Here's the extended discussion with more info: https://stackoverflow.com/questions/54913287/under-some-circumstances-operator-not-supported-for-strings-error-occurs-whe

Reproduced on both local (7.2.15, Ubuntu 16.04 x64), dev and production (7.2.15 RHEL 6) environments. Don't think It's related to environment or some modules, but here's the list of installed modules (tried to pick only additionally installed modules).

[PHP Modules]
...
gd
...
iconv
igbinary
imagick
...
mbstring
mcrypt
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
...
xdebug
xml
...
Zend OPcache
zip
zlib

[Zend Modules]
Xdebug
Zend OPcache

Excuse me for possible grammar errors and thanks in advance.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-02-28 10:18 UTC] nikic@php.net
-Status: Open +Status: Feedback
 [2019-02-28 10:18 UTC] nikic@php.net
Can you please check whether this issue goes away if you remove the xdebug and opcache extensions?
 [2019-03-01 15:47 UTC] dantaeusb at live dot com
Yes, seems like it's happening only if XDebug enabled! Even if the extension is only loaded and not enabled, I can see the error. It's not happening when I disable `zend_extension=xdebug.so` in config.
 [2019-03-01 15:50 UTC] dantaeusb at live dot com
-Status: Feedback +Status: Open -Package: Arrays related +Package: Xdebug
 [2019-03-01 15:50 UTC] dantaeusb at live dot com
So as it seems to be XDebug related I'm changing the package from Arrays related to PECL/XDebug. Let me know if I can provide some more data to help fix the bug.
 [2020-01-20 17:14 UTC] derick@php.net
-Status: Open +Status: Wont fix
 [2020-01-20 17:14 UTC] derick@php.net
If this is Xdebug related, please file a bug report at https://bugs.xdebug.org
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 08 11:01:27 2024 UTC