Bug #62680 [Ver]: Function isset() throws fatal error on set array if non-existent key depth >= 3
Edit report at https://bugs.php.net/bug.php?id=62680&edit=1
ID: 62680
Updated by: laruence@php.net
Reported by: kriscraig@php.net
Summary: Function isset() throws fatal error on set array if
non-existent key depth >= 3
Status: Verified
Type: Bug
Package: Arrays related
Operating System: Linux and Windows
PHP Version: 5.3.15
Block user comment: N
Private report: N
New Comment:
I'd like mark this as won't fix for 5.3, fixing this will be a big work IMO, maybe
introduce new issues, and 5.3 is quite stable version now.
Previous Comments:
------------------------------------------------------------------------
[2012-07-30 18:32:12] kriscraig@php.net
Woops, drop the word "ternary" from the description/title. =)
------------------------------------------------------------------------
[2012-07-30 18:30:31] kriscraig@php.net
Oh and here's the test case:
--TEST--
Test for existence of ternary isset() bug in nested arrays.
--DESCRIPTION--
Errors should not be thrown when passing non-set arguments to isset().
--CREDIT--
Kris Craig <kriscraig@php.net>
--FILE--
<?php
$arr = array( "key" => "",
"key2" => array( "subkey" => array( "supersubkey" => array(
"superdupersubkey" => "Hello." ) ) ),
"key3" => array( "subkey" => array( "supersubkey" =>
"Hello." ) ) );
if ( isset( $arr["key"]["non_existant_key"] ) )
{
print "Arroooo?";
}
print "DEBUG #1.<br />\r\n";
$out = ( isset( $arr["key"]["non_existent_key"] ) ? "WTF?!" : NULL );
print "DEBUG #2.<br />\r\n";
foreach ( $arr as $key => $row )
{
print ( isset( $row["subkey"]["supersubkey"] ) ?
$row["subkey"]["supersubkey"] . "<br />\r\n" : NULL );
}
print "DEBUG #3.<br />\r\n";
/* Ternaries. --Kris */
print ( isset(
$some_non_existent_variable[0]["subkey"]["supersubkey"]["superdupersubkey"]
) ? "BAD<br />\r\n" : "OK<br />\r\n" );
print ( isset( $arr[0]["subkey"]["supersubkey"]["superdupersubkey"] )
? "BAD-0<br />\r\n" : "OK-0<br />\r\n" );
print ( isset(
$arr["key"]["subkey"]["supersubkey"]["superdupersubkey"] ) ?
"BAD-1<br />\r\n" : "OK-1<br />\r\n" );
print ( isset(
$arr["key2"]["subkey"]["supersubkey"]["superdupersubkey"] )
? "OK-2<br />\r\n" : "BAD-2<br />\r\n" );
print ( isset(
$arr["key3"]["subkey"]["supersubkey"]["superdupersubkey"] )
? "BAD-3<br />\r\n" : "OK-3<br />\r\n" );
/* Ifcheck. --Kris */
if ( isset(
$arr["key"]["subkey"]["supersubkey"]["superdupersubkey"] ) )
{
die( "Error : T_PAAMAYIM_NEKUDOTAYIM is too hard to pronounce!" );
}
print "DEBUG #4.<br />\r\n";
foreach ( $arr as $key => $row )
{
print ( isset( $row["subkey"]["supersubkey"]["superdupersubkey"] ) ?
$row["subkey"]["supersubkey"]["superdupersubkey"] . "<br
/>\r\n" : NULL );
}
print "DEBUG #5.";
?>
--EXPECT--
DEBUG #1.<br />
DEBUG #2.<br />
Array<br />
Hello.<br />
DEBUG #3.<br />
OK-0<br />
OK-1<br />
OK-2<br />
OK-3<br />
DEBUG #4.<br />
Hello.<br />
DEBUG #5.
------------------------------------------------------------------------
[2012-07-30 18:27:15] kriscraig@php.net
Ahh ok. Is this a won't fix then since it's not in 5.4? Or is this still something
we'd want to correct?
Thanks!
------------------------------------------------------------------------
[2012-07-28 07:34:31] laruence@php.net
yeah, this is a issue in 5.3, while 5.4 have no such issue which is due to the
fetch_dim_is behavior changed
------------------------------------------------------------------------
[2012-07-27 23:04:52] kriscraig@php.net
I'm still fairly new to the codebase compared to most of you karma folks, so if this looks like
something a relative newbie could handle, please point me in the right direction and I'd be
happy to just assign this one to myself. It'll probably take way longer but I imagine it would
be a good learning experience for me if I had a little guidance to get me started.
Thanks! =)
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=62680
--
Edit this bug report at https://bugs.php.net/bug.php?id=62680&edit=1
Thread (9 messages)