Bug #74836 [Asn->Csd]: isset on zero-prefixed numeric indexes in array broken

From: Date: Tue, 04 Jul 2017 04:24:15 +0000
Subject: Bug #74836 [Asn->Csd]: isset on zero-prefixed numeric indexes in array broken
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209795@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74836&edit=1

 ID:                 74836
 Updated by:         dmitry@php.net
 Reported by:        sjon at hortensius dot net
 Summary:            isset on zero-prefixed numeric indexes in array
                     broken
-Status:             Assigned
+Status:             Closed
 Type:               Bug
 Package:            Arrays related
 Operating System:   3v4l.org
 PHP Version:        7.2.0alpha2
 Assigned To:        dmitry
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=bfa24e34889ec8840bc86c5c39afcfb353d06567
Log: Fixed bug #74836 (isset on zero-prefixed numeric indexes in array broken)


Previous Comments:
------------------------------------------------------------------------
[2017-07-03 06:57:43] dmitry@php.net

Also see: https://3v4l.org/SDpff

<?php
$a = "1234567890a";
$b[10] = "42";
$i = "010";
var_dump($a["10"], isset($a["10"]));
var_dump($a["010"], isset($a["010"]));
var_dump($a[$i], isset($a[$i]));
var_dump($b["10"], isset($b["10"]));
var_dump($b["010"], isset($b["010"]));
var_dump($b[$i], isset($b[$i]));

Actual result:
--------------
string(1) "a"
bool(true)
string(1) "a"
bool(false)
string(1) "a"
bool(true)
string(2) "42"
bool(true)

Notice: Undefined index: 010 in /in/N9KcU on line 9
NULL
bool(false)

Notice: Undefined index: 010 in /in/N9KcU on line 10
NULL
bool(false) 

It seems, we interpret zero-prefexed numeric indexes inconsistently.
I think, we should disable string-to-number conversion for all zero-prefexed cases.

------------------------------------------------------------------------
[2017-07-01 11:01:40] bwoebi@php.net

Related: http://git.php.net/?p=php-src.git;a=commitdiff;h=8fe47a47cf30eb3bf50a5cdb4e07f6fa135d21c7

Assigning to Dmitry, the commits author.

------------------------------------------------------------------------
[2017-06-30 13:46:55] sjon at hortensius dot net

Description:
------------
there seems to be bug when using quoted numeric indexes combined with isset(). It works without the
(redundant) 0 prefix: https://3v4l.org/NQvXb

Test script:
---------------
See https://3v4l.org/3fXr6


<?php

$a = "1234567890a";
var_dump($a["010"], isset($a["010"])); // true

Expected result:
----------------
string(1) "a"
bool(true)

Actual result:
--------------
string(1) "a"
bool(false)


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=74836&edit=1


Thread (4 messages)

« previous php.bugs (#209795) next »