Problem/Motivation

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()"

Proposed resolution

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

wolfhowling created an issue. See original summary.

wolfhowling’s picture

Issue summary: View changes