diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php index f8c9613..2884741 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php @@ -269,10 +269,10 @@ public function save(array $link) { * A definition, according to $definitionFields, for a * \Drupal\Core\Menu\MenuLinkInterface plugin. * - * @return array + * @return string[] * The menu names affected by the save operation. This will be one menu - * name if the link is saved to the sane menu, or two if it is saved to a - * new menu. + * name if the link is saved to the same menu, or two if it is saved to a + * new menu. If saving the menu is not necessary, it will be an empty array. * * @throws \Exception * Thrown if the storage back-end does not exist and could not be created. @@ -305,7 +305,8 @@ protected function doSave(array $link) { // - MenuTreeStorage::preSave() removes the 'mlid' from $fields. // - The order of the keys in $original and $fields is different. if (array_diff_assoc($fields, $original) == [] && array_diff_assoc($original, $fields) == ['mlid' => $link['mlid']]) { - return $affected_menus; + // No menus are affected. + return []; } $affected_menus[$original['menu_name']] = $original['menu_name']; } diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php b/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php index f0c61d0..f001e3f 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php @@ -91,16 +91,16 @@ public function loadByRoute($route_name, array $route_parameters = [], $menu_nam /** * Saves a plugin definition to the storage. * - * This function can provide optimizations to avoid saves, when there have - * been no changes. This should be reflected in the return value. + * This function can provide optimizations to avoid saves if there are no + * changes. This should be reflected in the return value. * * @param array $definition * A definition for a \Drupal\Core\Menu\MenuLinkInterface plugin. * * @return string[] * The menu names affected by the save operation. This will be one menu - * name if the link is saved to the sane menu, or two if it is saved to a - * new menu. + * name if the link is saved to the same menu, or two if it is saved to a + * new menu. If saving the menu is not necessary, it will be an empty array. * * @throws \Exception * Thrown if the storage back-end does not exist and could not be created. diff --git a/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php b/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php index b52f646..a758d4f 100644 --- a/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php @@ -366,7 +366,7 @@ public function testLoadByProperties() { /** * Tests saving without any changes. - */ + */ public function testResaving() { $affected_menus = $this->addMenuLink('root'); $this->assertEquals(['tools' => 'tools'], $affected_menus);