|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66058 Add a new Array value makes a RECURSIVE Value
Submitted: 2013-11-08 09:03 UTC Modified: 2014-05-08 16:21 UTC
From: jkt at steampower dot hu Assigned:
Status: No Feedback Package: Arrays related
PHP Version: 5.4.21 OS: Windows XP SP3
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-11-08 09:03 UTC] jkt at steampower dot hu
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'];
    $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'];
	}else {
		$ret[$j]['EgysegID'] = $d['EgysegID']; // This is goes RECURSIVE
		$ret[$j]['Jogosultsag'] = $d['Jogosultsag'];
	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*


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-11-08 18:45 UTC]
-Status: Open +Status: Feedback
 [2013-11-08 18:45 UTC]
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).
 [2014-05-08 16:21 UTC]
-Status: Feedback +Status: No Feedback
 [2014-05-08 16:21 UTC]
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Feb 22 14:01:29 2024 UTC