diff --git a/composer.json b/composer.json index ea9e7e0e..eb6bf5c7 100644 --- a/composer.json +++ b/composer.json @@ -18,10 +18,10 @@ "source": "https://github.com/cakephp/elastic-search" }, "require": { + "cakephp/cakephp": "^4.0", "ruflin/elastica": "^6.0" }, "require-dev": { - "cakephp/cakephp": "^4.0", "cakephp/cakephp-codesniffer": "^4.0", "phpunit/phpunit": "^8.5" }, diff --git a/src/Marshaller.php b/src/Marshaller.php index 17f58cd3..96730d57 100644 --- a/src/Marshaller.php +++ b/src/Marshaller.php @@ -293,14 +293,16 @@ public function merge(EntityInterface $entity, array $data, array $options = []) public function mergeMany(array $entities, array $data, array $options = []) { $indexed = (new Collection($data)) - ->groupBy('id') + ->groupBy(function ($element) { + return $element['id'] ?? ''; + }) ->map(function ($element, $key) { return $key === '' ? $element : $element[0]; }) ->toArray(); - $new = $indexed[null] ?? []; - unset($indexed[null]); + $new = $indexed[''] ?? []; + unset($indexed['']); $output = []; foreach ($entities as $record) {