Skip to content
Permalink
Browse files

Fix notice when passing false.

  • Loading branch information...
dereuromark committed Mar 14, 2018
1 parent 68de980 commit b68f1cbb1f02351e1ddde13fffddb13a206e5517
Showing with 17 additions and 15 deletions.
  1. +17 −15 lib/Cake/Model/Datasource/DboSource.php
@@ -1566,23 +1566,25 @@ protected function _mergeHasMany(&$resultSet, $assocResultSet, $association, Mod
// Make one pass through children and collect by parent key
// Make second pass through parents and associate children
$mergedByFK = array();
foreach ($assocResultSet as $data) {
$fk = $data[$association][$foreignKey];
if (! array_key_exists($fk, $mergedByFK)) {
$mergedByFK[$fk] = array();
}
if (count($data) > 1) {
$data = array_merge($data[$association], $data);
unset($data[$association]);
foreach ($data as $key => $name) {
if (is_numeric($key)) {
$data[$association][] = $name;
unset($data[$key]);
if (is_array($assocResultSet)) {
foreach ($assocResultSet as $data) {
$fk = $data[$association][$foreignKey];
if (! array_key_exists($fk, $mergedByFK)) {
$mergedByFK[$fk] = array();
}
if (count($data) > 1) {
$data = array_merge($data[$association], $data);
unset($data[$association]);
foreach ($data as $key => $name) {
if (is_numeric($key)) {
$data[$association][] = $name;
unset($data[$key]);
}
}
$mergedByFK[$fk][] = $data;
} else {
$mergedByFK[$fk][] = $data[$association];
}
$mergedByFK[$fk][] = $data;
} else {
$mergedByFK[$fk][] = $data[$association];
}
}

0 comments on commit b68f1cb

Please sign in to comment.
You can’t perform that action at this time.