That would likely be because of the highlighted code found in the Move method of the queryFactoryResult class located in includes/classes/db/mysql/query_factory.php (with similar issue in the ExecuteRandomMulti method):
Code:
/**
* Moves the cursor to the specified row. If the row is not valid,
* the cursor will be moved past the last row and EOF will be set false.
*
* @param int $zp_row the row to move to
*/
public function Move($zp_row) {
global $db;
if ($this->is_cached) {
if($zp_row >= sizeof($this->result)) {
$this->cursor = sizeof($this->result);
$this->EOF = true;
} else {
while(list($key, $value) = each($this->result[$zp_row])) {
$this->fields[$key] = $value;
}
$this->cursor = $zp_row;
$this->EOF = false;
}
} else if (@mysqli_data_seek($this->resource, $zp_row)) {
$zp_result_array = @mysqli_fetch_array($this->resource);
while (list($key, $value) = each($zp_result_array)) {
$this->fields[$key] = $value;
}
$this->cursor = $zp_row;
$this->EOF = false;
} else {
$this->EOF = true;
$db->set_error(mysqli_errno($this->link), mysqli_error($this->link), $db->dieOnErrors);
}
}
As identified in the PHP Manual for the mysqli_fetch_array function, When performing a mysqli_fetch_array with no further resulttype identifier, then both the numeric as well as associative result(s) are provided. In cases/uses outside of the Move method and ExecuteRandomMulti method, the numeric index is prevented from being added to the result, which also excludes the possibility of a field being identified as a number (which is possible with mysql if the field, when used/referenced, is backquoted (`` not '').
Therefore, if it is in fact considered that no field/index should be numeric only then the following changes would be expected with line numbers provided from the github tracked ZC 1.5.5f version (centrally, the issue affects all of ZC 1.5.X (at least up to 1.5.5f and then 1.5.6) as well 1.6.0).
The reason that this is now so "visible" is because the queryFactoryResult class implements the Iterator class to support the foreach operation and centrally its use of the Move(0) call within the Rewind method which is called as part of the Iterator class.
Beginning at line 711 changing:
Code:
} else if (@mysqli_data_seek($this->resource, $zp_row)) {
$zp_result_array = @mysqli_fetch_array($this->resource);
while (list($key, $value) = each($zp_result_array)) {
$this->fields[$key] = $value;
}
to:
Code:
} else if (@mysqli_data_seek($this->resource, $zp_row)) {
$zp_result_array = @mysqli_fetch_array($this->resource);
while (list($key, $value) = each($zp_result_array)) {
if (!preg_match('/^[0-9]/', $key)) { // mc12345678 prevent numeric index result from being stored.
$this->fields[$key] = $value;
}
}
and beginning at line 327 changing:
Code:
$zp_result_array = @mysqli_fetch_array($zp_db_resource);
if ($zp_result_array) {
$obj->result[$zp_ii] = array();
while (list($key, $value) = each($zp_result_array)) {
$obj->result[$zp_ii][$key] = $value;
}
} else {
to:
Code:
$zp_result_array = @mysqli_fetch_array($zp_db_resource);
if ($zp_result_array) {
$obj->result[$zp_ii] = array();
while (list($key, $value) = each($zp_result_array)) {
if (!preg_match('/^[0-9]/', $key)) { // mc12345678 prevent numeric index result from being stored for use.
$obj->result[$zp_ii][$key] = $value;
}
}
} else {