Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By tim.plunkett on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
\Drupal\Component\Utility\NestedArray::mergeDeep() was introduced to solve the oddities of PHP's built in array_merge_recursive().
However, it was not always used, causing potential problems for contrib or custom modules.
Now all but one usage of array_merge_recursive() has been removed from core.
When a function is in the critical path, and is called many many times per page, and has little to no possibility of needing the more advanced NestedArray::mergeDeep(), array_merge_recursive() can be used.
// D7
$return = array_merge_recursive($return, $result);
// D8
use Drupal\Component\Utility\NestedArray;
$return = NestedArray::mergeDeep($return, $result);
// D7
$data = call_user_func_array('array_merge_recursive', $settings['data']);
// D8
use Drupal\Component\Utility\NestedArray;
$data = NestedArray::mergeDeepArray($settings['data'])
Impacts:
Module developers