Bug #62680 [Com]: 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
Comment by: kriscraig@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:
@Laruence Sorry for the delay; they're keeping me busy up here!
Yeah I have no objection. It really sucks but I have to agree. Since it's fixed in 5.4, it
really wouldn't be worth tearing into 5.3's guts just to correct this.
I'll go ahead and mark it "won't fix" for ya (as I try to think happy thoughts).
=)
Previous Comments:
------------------------------------------------------------------------
[2012-07-31 02:48:17] laruence@php.net
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.
------------------------------------------------------------------------
[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
------------------------------------------------------------------------
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)