Active
Project:
Disable Node Menu Item - D8 port
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Sep 2022 at 19:45 UTC
Updated:
14 Sep 2022 at 19:46 UTC
Jump to comment: Most recent
After the site is updated to Drupal 9.4 the module causes a site error. On the logs it displays "Error: Attempt to assign property "value" on null in Drupal\menu_link_content\Plugin\Menu\MenuLinkContent->updateLink()"
I was able to get it up and working again by changing the code starting on line 81 from this:
if(sizeof($menu_links)){
foreach ($menu_links as $menu_link) {
$definition = $menu_link->getPluginDefinition();
$definition['enabled'] = $form_state->getValue(['menu','link_enabled']);
$menu_link_manager->updateDefinition($menu_link->getPluginId(), $definition);
}
}
to this:
if(!empty($menu_links)){
foreach ($menu_links as $menu_link) {
$id = $menu_link->getPluginDefinition()['metadata']['entity_id'];
$link = \Drupal::entityTypeManager()->getStorage('menu_link_content')->load($id);
$link->set('enabled', $form_state->getValue(['menu','link_enabled']));
$link->save();
}
}
I am not sure if this is the best way to go about it but so far it works.
Comments
Comment #2
wolfhowling commented