Bug #66058 [Opn->Fbk]: Add a new Array value makes a RECURSIVE Value
| From: | requinix@php.net | Date: | Fri, 08 Nov 2013 18:45:30 +0000 |
| Subject: | Bug #66058 [Opn->Fbk]: Add a new Array value makes a RECURSIVE Value | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-182668@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66058&edit=1
ID: 66058
Updated by: requinix@php.net
Reported by: jkt at steampower dot hu
Summary: Add a new Array value makes a RECURSIVE Value
-Status: Open
+Status: Feedback
Type: Bug
Package: Arrays related
Operating System: Windows XP SP3
PHP Version: 5.4.21
Block user comment: N
Private report: N
New Comment:
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
That script isn't something we can use to reproduce the issue. It needs to be as self-contained
as possible: no database, no other functions called, and not an excerpt of some code from within a
function.
Also, the "expected result" is probably not what you actually expect (shouldn't it be
[1] => Array... at the end?) and the "actual result" isn't possible ([1] => [1]
=> is invalid).
Previous Comments:
------------------------------------------------------------------------
[2013-11-08 09:03:04] jkt at steampower dot hu
Description:
------------
There is a short function, which starts one query and then parse the results.
If the script goes to commented line, the $ret array new value makes a recursive array.
I checked set the value by hand, like ='35';, but the PHP do the same.
I think it's a bug, because I downgrade the v5.3.27 and the script functional normally again.
Test script:
---------------
$ret = Array();
$query = "SELECT * FROM any WHERE ID=".html2sql($ID).";";
$results = mysqli_query($connectedID, $query);
if (mysqli_num_rows($results)) {
$i = 0;
while ($row = mysqli_fetch_assoc($results)) {
$r[$i]['GyujtoEgysegID'] = $row['GyujtoEgysegID'];
$r[$i]['EgysegID'] = $row['EgysegID'];
$r[$i]['Jogosultsag'] = $row['Jogosultsag'];
$i++;
};
$j = 0;
foreach ($r as $d) {
if ($d['GyujtoEgysegID'] != '') {
$gye = GET_user_egysegGyujto($d['GyujtoEgysegID']);
foreach ($gye as $e) {
$ret[$j]['EgysegID'] = $e['EgysegID'];
$ret[$j]['Jogosultsag'] = $d['Jogosultsag'];
$j++;
};
}else {
$ret[$j]['EgysegID'] = $d['EgysegID']; // This is goes RECURSIVE
$ret[$j]['Jogosultsag'] = $d['Jogosultsag'];
$j++;
};
};
return $ret;
}else {
return false;
};
Expected result:
----------------
Something like this:
$ret = Array([0] => Array('EgysegID' => 2, 'Jogosultsag' => 1),
Array...
Actual result:
--------------
$ret = Array([0] => Array('EgysegID' => 2, 'Jogosultsag' => 1),
Array([1] => [1] => *RECURSIVE*
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66058&edit=1