Problem/Motivation

Drupal 8 install
Make sure you have "page" content type defined
Go to Admin / Structure / Menus / Administration admin/structure/menu/manage/admin.
Find the link points to menu link item Adminstration / Structure / Content types / Basic page admin/structure/menu/link/entity.node_type.edit_form.page/edit.

Proposed resolution

Define a new function called _admin_toolbar_tools_menu_links_discovered_alter_set_link
Before link append to list it makes sure provider property is not empty.

Every new item registered by admin_toolbar_tools_menu_links_discovered_alter is added by this new function.

Remaining tasks

Test the patch.

User interface changes

None.

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jody Lynn created an issue. See original summary.

Jody Lynn’s picture

Project: Drupal core » Admin Toolbar
Version: 8.6.x-dev » 8.x-1.x-dev
Component: node system » Code

These menu links are actually added by admin_toolbar_tools module and I likewise cannot edit links it adds such as field_ui.entity_form_mode_add

Jody Lynn’s picture

I believe hook_menu_links_discovered_alter is not the correct way to add dynamic menu items. This looks like the right way: https://www.webomelette.com/dynamic-menu-links-drupal-8-plugin-derivatives

adriancid’s picture

Hi @Jody Lynn thanks for reporting, can you use the next time the Issue Summary Template? I will try to reproduce the issue now.

adriancid’s picture

I see the problem, we will try to fix it.

tikaszvince’s picture

tikaszvince’s picture

Status: Active » Needs review
FileSize
27.75 KB

Steps to reproduce

Drupal 8 install
Make sure you have "page" content type defined
Go to Admin / Structure / Menus / Administration admin/structure/menu/manage/admin.
Find the link points to menu link item Adminstration / Structure / Content types / Basic page admin/structure/menu/link/entity.node_type.edit_form.page/edit.

You got the fatal error mentioned in the description.

Proposed resolution

The attached patch defines a new function called _admin_toolbar_tools_menu_links_discovered_alter_set_link
Before link append to list it makes sure provider property is not empty.

Every new item registered by admin_toolbar_tools_menu_links_discovered_alter is added by this new function.

Jody Lynn’s picture

Status: Needs review » Needs work

Thanks tikaszvince for the fix. I think adding that function makes everything more complex and harder to read. Can we just add 'provider' into each link?

adriancid’s picture

Issue summary: View changes
tikaszvince’s picture

I think which solution is easier or harder to read is a question of habit. I think this admin_toolbar_tools_menu_links_discovered_alter is already a too complex function. It contains a lots of code repetition. In this form its easy to miss something. With that new function we could make sure new links has every required properties.

But sure, I attached an other patch, which do the same without an extra function.

tikaszvince’s picture

Status: Needs work » Needs review
Jody Lynn’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @tikaszvince. I've tested #10 and confirmed the fix.

adriancid credited grahl.

adriancid’s picture

Title: Fatal error when editing node.add.* menu links » Provider property missing on link definition
Related issues: +#3011919: Admin Toolbar Tools adds broken theme settings links

I'm giving credit here to the other 2 issues where the problem was reported and I've changed the issue title to other more general.

  • adriancid committed c838100 on 8.x-1.x authored by tikaszvince
    Issue #3012102 by tikaszvince, Jody Lynn, adriancid, grahl, jigarius:...
adriancid’s picture

Status: Reviewed & tested by the community » Fixed

Thanks to @all to help to solve this problem :-)

@eme and @romainj I think we should release a new module version with this patch.

  • adriancid committed 15f34d8 on 8.x-1.x
    Issue #3012102 by tikaszvince, Jody Lynn, adriancid, grahl, jigarius:...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.