Just started working with this module in-tandem with Layout Builder and running into an issue where upon enabling Layout Builder for the menu under the Manage Display tab.
I can no longer visit the Manage Display tab and get this error:
Drupal\Core\Database\InvalidQueryException: Query condition 'menu_link_content.uuid IN ()' cannot be empty. in Drupal\Core\Database\Query\Condition->condition() (line 103 of /var/www/docroot/core/lib/Drupal/Core/Database/Query/Condition.php).
Which appears to be coming from src/Entity/MenuItemExtrasMenuLinkContent.php
on line 32. The parent_uuid
value seems to be null (and $this->getParentId()
seems to return an incomprehensible value that looks like a generated value from Devel) and so the EntityTypeManager throws an error because uuid cannot be null when searching.
There might be an underlying issue that I cannot seem to find, but adding a simple null check here seems to alleviate the issue.
Comment | File | Size | Author |
---|---|---|---|
#10 | 3032279-2.patch | 2.24 KB | jmarcou |
| |||
#2 | 3032279-1.patch | 1.39 KB | Justin Langley |
|
Comments
Comment #2
Justin Langley CreditAttribution: Justin Langley as a volunteer commentedComment #3
ozinComment #4
PCate CreditAttribution: PCate as a volunteer commentedI ran into the same error and the patch fixed it.
Comment #5
ozinHi @justin@codekoalas.com
Thanks for the patch! What do you think about a test coverage for this case?
Comment #6
JulianVJ CreditAttribution: JulianVJ commentedHi
I also ran into the same error and I've been debugging a little because I didn't find this issue.
I want to write down here what I have found in case it could be of help to someone else
This error happens with a sample entity generated by Layout Builder and stored in TempStore. It seems that Layout Builder generates this samples entities when a new supported entity is created, this is what happens when Menu Item Extras is enabled. See: core\modules\layout_builder\src\Entity\LayoutBuilderSampleEntityGenerator.php -> get().
The patch attached by @justincodekoalascom works correctly. I think is a good idea to add a test coverage
Comment #7
m.abdulqader CreditAttribution: m.abdulqader at Sprintive commentedThe patch fixes the issue for us.
Thank you
Comment #9
jmarcou CreditAttribution: jmarcou commentedSeems like this is not entirely fixed, I'm now getting a :
Notice: Undefined offset: 1 in Drupal\menu_item_extras\Entity\MenuItemExtrasMenuLinkContent->getCacheTagsToInvalidate() (line 32 of modules/contrib/menu_item_extras/src/Entity/MenuItemExtrasMenuLinkContent.php).
(you need to clear the cache every time you reload your page to see this, because of the cache).
This is caused by the fact that I have created a static menu link inside a module (my_module.links.menu.yml) that extends MenuLinkDefault, these kind of links does not work as other menu links and don't have an ID like "menu_link_content:{uuid}", in my case the ID looks like "my_module.my_menu_name".
These kind of links should not be loaded like other menu links, I don't know how to do it, but I think it should definitely call the cache methods of my class that extends MenuLinkDefault.
Comment #10
jmarcou CreditAttribution: jmarcou commentedIn addition to you previous commit, I updated the code to create a new patch (for the people that are on the
8.x-2.4 version, you'll need to apply patch 3032279-1.patch and 3032279-2.patch in order to make it works).
So finally, my solution was to check for the prefix string "menu_link_content:" instead of exploding the string by ":".
Then if it has the prefix, I used the same solution as before (loading the menu link content entity from storage), otherwise I use the MenuLinkManager service, which allows to load static menu links as MenuLinkInterface, on which I can call the getCacheTags() method.
Comment #11
jmarcou CreditAttribution: jmarcou commentedComment #12
volegerLooks good. Thanks a lot @jmarcou for your so descriptive comments.
Comment #13
rodrigoaguileraI can confirm the patch in #10 works as intended. please commit it
Comment #15
Justin Langley CreditAttribution: Justin Langley as a volunteer commentedI had totally forgotten I submitted this a while back! Glad to see someone improved on what I was trying to do. I ended up back here because I was searching for the exact issue mentioned in #9.
Comment #16
volegerFix already published in 8.x-2.5 release version. Thanks.