0

This question is related to two issues on drupal.org:

Summary

How to delete a menu item that was defined in example.links.menu.yml and then changed, for example by disabling it or changing its weight.

Steps to reproduce

  • Install a clean Drupal 8 with the Standard installation profile
  • Go to admin/structure/menu/manage/main and disable the Home menu item. This change will write the menu item to core.menu.static_menu_link_overrides.
  • Delete file core/profiles/standard/standard.links.menu.yml
  • Clear cache
  • Try to delete the now orphaned menu item:

    $home_manager = \Drupal::service('plugin.manager.menu.link');
    $home_manager->removeDefinition('standard.front_page');
    

Expected behavior

We are able to delete the menu item.

Actual behavior

We get the following error:

Uncaught PHP Exception Drupal\Component\Plugin\Exception\PluginException: "Menu link plugin with ID 'standard.front_page' does not support deletion".

Question

Is this a bug in Drupal core, or am I using the wrong way to delete the menu item?

  • Steps to reproduce Delete file core/profiles/standard/standard.links.menu.yml ummmm... core files should never be deleted. – No Sssweat Feb 20 '17 at 6:48
  • Cfr issue on d.o make "Home" menu link to editable/deletable. We're trying to get rid of standard.links.menu.yml and we need an upgrade path. This also works with any other link created in an example.links.menu.yml file. – Wim Mostrey Feb 20 '17 at 6:50
  • You seem to have reported it as a bug so the answer is "yes" isn't it? – Clive Feb 20 '17 at 7:46
  • I want to know if it is actually a bug, or if I'm missing something. I want to be prepared for core mentoring hour next week. – Wim Mostrey Feb 20 '17 at 7:48
  • @WimMostrey There is nothing that that would require you to delete a core file. You're basically hacking core at this point. There is a rule of thumb that you never touch core. – No Sssweat Feb 20 '17 at 8:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.