If the menu_link module is not enabled, the following code is run:

    // The Menu link module is not available at install time, so we need to
    // hardcode the default storage controller.
    $menu_link_controller = new MenuLinkStorageController('menu_link', Drupal::service('database'), Drupal::service('router.route_provider'));

but the signature of the constructor has the entity_info as second parameter.
You can't get this information from Drupal::entityManager()->getDefinition('menu_link'), so you might have to copy it from MenuLink.php in the menu_link module.

Comments

amateescu’s picture

Do we have some steps to reproduce this? I haven't seen that code path used in a long time..

amateescu’s picture

Also, I'm pretty sure it was working when I wrote it in the original conversion issue.. seems that it was broken by #1909418: Allow Entity Controllers to have their dependencies injected :/

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new1.52 KB

Well, at some point the menu_link module is not enabled, depending on your speed of your batch process. I can reproduce that on 50% of the UI installations.

Sorry I had to fix that myself, as it was too annoying.

dawehner’s picture

Issue tags: +MenuSystemRevamp

Change component.

pwolanin’s picture

Issue tags: -MenuSystemRevamp

This seems to change the constructor for MenuLinkStorageController() ?

Can we look to see if the info is missing and parse it form the yaml? Better than hard-coding it.

pwolanin’s picture

Issue tags: +MenuSystemRevamp
StatusFileSize
new1.03 KB

How about this much simpler version?

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Way better!
install_finished triggers drupal_flush_all_caches which triggers menu_router_rebuild which triggers _menu_navigation_links_rebuild so this will never fail, as you never need menu links during the installer.

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

There was an issue somewhere to add _menu_navigation_links_rebuild() into menu_links module entirely, but I can't find it.

Fine with this for a quick fix since that's a much bigger change, would be good to cross-link though.

This ought to be possible to test?

pwolanin’s picture

@catch - it's apparently 50/50 during install, so I'm not sure how to make a consistent test for it?

catch’s picture

Test could look like this I think:

Have a module handler without menu_link module in the list.

Call _menu_navigation_links_rebuild()

amateescu’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs tests

That will only test that ModuleHandler::moduleExists() works, which I'm pretty sure it is already covered in the dedicated module handler tests. I don't think we can do anything more here..

catch’s picture

Status: Reviewed & tested by the community » Fixed

Hmm well it'd continue to work if the function gets refactored too, but fair enough.

Committed/pushed to 8.x.

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