service ID: menu_link.static.overrides
class: Drupal\Core\Menu\StaticMenuLinkOverrides
method: saveOverride($id, array $definition)
To make it easy to see, copy the method's code here exactly as it was::
public function saveOverride($id, array $definition) {
// Only allow to override a specific subset of the keys.
$expected = [
'menu_name' => '',
'parent' => '',
'weight' => 0,
'expanded' => FALSE,
'enabled' => FALSE,
];
// Filter the overrides to only those that are expected.
$definition = array_intersect_key($definition, $expected);
// Ensure all values are set.
$definition = $definition + $expected;
if ($definition) {
// Cast keys to avoid config schema during save.
$definition['menu_name'] = (string) $definition['menu_name'];
$definition['parent'] = (string) $definition['parent'];
$definition['weight'] = (int) $definition['weight'];
$definition['expanded'] = (bool) $definition['expanded'];
$definition['enabled'] = (bool) $definition['enabled'];
$id = static::encodeId($id);
$all_overrides = $this->getConfig()->get('definitions');
// Combine with any existing data.
$all_overrides[$id] = $definition + $this->loadOverride($id);
$this->getConfig()->set('definitions', $all_overrides)->save(TRUE);
}
return array_keys($definition);
}
the line:
$all_overrides[$id] = $definition + $this->loadOverride($id);
the "+" operation makes no sense,It doesn't do anything,Because all the keys already exist.
And the $id is also wrong,It has been processed by the encodeId()
While there will be no errors and the tests will be no problems,
but this wastes performance and is not elegant
needs to be fixed