Problem/Motivation
menu_link_rebuild_defaults() unsets \Drupal\menu_link\Entity\MenuLink::menu_name instead of resetting its value. This causes failures in \Drupal\menu_link\MenuLinkStorageController, which expects the property to exist.
Proposed resolution
Set the value to NULL, rather than unsetting the entire property.
Remaining tasks
None.
User interface changes
None.
API changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | drupal_2198571_10.patch | 639 bytes | xano |
Comments
Comment #1
xanoComment #2
xanoComment #3
berdirWhile I agree with the fix, I've usually seen this when a parent menu link is referenced that doesn't exist.
unset() is definitely wrong, but I would argue that it is a mandatory information now (as menu links need to live in a menu?), and when it is missing it should be handled *somehow* and not silently ignored. I'm not sure how... exception? watchdog?
Especially the typical reason for this (missing parent definition) should probably be handled earlier, again, *somehow*.
Comment #4
xanoSee #2198619: Validate default menu link definitions.
Comment #5
sunThanks for the follow-up issue to address @Berdir's concern. This looks good to me.
Comment #6
dawehner+1
Comment #7
tim.plunkettThis made me expect test coverage... What's up with that?
Comment #8
berdirThe only way that I'm aware of is an invalid default menu link, and the issue linked above is supposed to change that.
This is only a follow-up of that, and fixing that should prevent that this will happen, so this is really just a small cleanup because using unset() on class properties is just wrong.
Comment #9
alexpottNo longer unsetting :) Since http://uk1.php.net/property_exists will return something different after this change I suggest changing the comment to something like "Set the default menu name to NULL so it's populated from the parent."
Comment #10
xanoComment #11
berdirUpdated comment looks fine, forgot about this issue.
Comment #13
tim.plunkett10: drupal_2198571_10.patch queued for re-testing.
Comment #14
dawehnerIt is still green.
Comment #15
alexpottCommitted de35da9 and pushed to 8.x. Thanks!
Comment #16
jbrown commentedI get this error now when I enable a contrib module:
Comment #17
jbrown commentedAdding 'menu_name' => 'admin', to composer_manager_menu_link_defaults() fixes the problem:
http://drupalcode.org/project/composer_manager.git/blob/refs/heads/8.x-1...
I'm not sure if that module is doing something wrong or not.
Comment #18
jbrown commentedProblem solved. The parent routes had to be changed:
system.admin.config.system => system.admin_config_system