Problem/Motivation
Drupal core: 8.7.0-beta1
Bootstrap: 3.17.0
fontawesome_menu_icons: 1.5.0
When switching to non-bootstrap themes, such as Bartick, sub-theme of AdaptiveTheme, the errors as blew are gone. So I am wondering this is a bug of the Bootstrap theme.
Warning: assert(): $attributes, if set, must be an array or object of type \Drupal\Core\Template\Attribute failed in Drupal\Core\Template\TwigExtension->getLink() (line 285 of /var/www/html/web/core/lib/Drupal/Core/Template/TwigExtension.php) #0 /var/www/html/web/core/includes/bootstrap.inc(587): _drupal_error_handler_real(2, 'assert(): $attr...', '/var/www/html/w...', 285, Array) #1 [internal function]: _drupal_error_handler(2, 'assert(): $attr...', '/var/www/html/w...', 285, Array) #2 /var/www/html/web/core/lib/Drupal/Core/Template/TwigExtension.php(285): assert(false, '$attributes, if...') #3 /var/www/html/web/sites/default/files/php/twig/5ca0db9f2cd99_menu.html.twig_VUQ6iE4VQToBSVI9Bfo_dn2WZ/hy8u3Eo9C2k_NpuyYBd6kh3wsa0qpyBsqI3EjezVbAw.php(145): Drupal\Core\Template\TwigExtension->getLink('Expense Request...', Object(Drupal\Core\Url), NULL) #4 /var/www/html/vendor/twig/twig/src/Template.php(673): __TwigTemplate_1cdc7ede551542f24a1d35b3ce5dabeb1d4fde609ae1e6babc47569282368a5d->getmenu_links(Array, Object(Drupal\Core\Template\Attribute), 1, Array, Array) #5
...
Comment | File | Size | Author |
---|---|---|---|
#12 | menu_items_encounter_null_attributes-3045621-12.patch | 1.26 KB | imclean |
Comments
Comment #2
jungleComment #3
jungleSorry, the patch not working
Comment #4
imclean CreditAttribution: imclean at Digital Ink commentedsrc/templates/menu.html.twig
looks like a good place to start.Comment #5
imclean CreditAttribution: imclean at Digital Ink commentedSee also: #2558079: Assertions in \Drupal\Template\TwigExtension
Comment #6
imclean CreditAttribution: imclean at Digital Ink commentedThis occurs with menu_level > 0. Parameter 3 "attributes" is
null
when being passed toDrupal\Core\Template\TwigExtension->getLink()
in the compiled twig template:Comment #7
imclean CreditAttribution: imclean at Digital Ink commentedThis happens because the prepropress method isn't executed for the submenus so the attributes aren't added. This is a proof of concept which should resolve the issue.
Comment #8
jungleThanks Ian, the patch works for me.
removed trailing whitespaces:
Comment #9
markhalliwellMissing docblock, also method name is misleading. It's not actually adding attributes, it's converting them.
Comment #10
imclean CreditAttribution: imclean at Digital Ink commentedComment #11
imclean CreditAttribution: imclean at Digital Ink commentedMissed something in my haste.
Comment #12
imclean CreditAttribution: imclean at Digital Ink commentedDocblock doesn't need to be so verbose.
Comment #13
komlenic CreditAttribution: komlenic commentedI just encountered precisely this issue when upgrading from core 8.6.15 to 8.7.0. The patch in #12 fixes the issue.
Comment #14
rjl CreditAttribution: rjl as a volunteer commentedJust as komlenic (#13), I had the same problem after upgrading to 8.7.0 and the patch in #12 also worked for me. Thanks.
Comment #15
Leo Pitt CreditAttribution: Leo Pitt commentedSame as rjl and komlenic. Encountered issue in upgrade to 8.7.0. Patch in #12 resolved it. Thanks.
Comment #16
imclean CreditAttribution: imclean at Digital Ink commentedIt would be useful to find out why this has changed between 8.6.x and 8.7.x.
Comment #17
ñull CreditAttribution: ñull commentedI tried Bartik but had the same error there. Would need to try with a clean install to verify if this is not a core issue, but have no time to do so now. #12 fixes it at least for Bootstrap
Comment #19
markhalliwellComment #20
chris5156Same issue as others when upgrading to 8.7.0 and using Bootstrap theme. The patch in #12 fixed the issue for me too.
Comment #21
astringer CreditAttribution: astringer as a volunteer commented@imclean
I was curious too.
https://www.drupal.org/project/drupal/issues/2917653
TLDR; Because depending on whether or not Toolbar was enabled, $variables['attributes'] could be an array or an object.
Thanks for the patch.
Comment #22
firfin CreditAttribution: firfin commentedMany people updating to 8.7 will run into this. Maybe time for a new release?
Comment #23
komlenic CreditAttribution: komlenic commentedI don't know if it fits into any other plans, but I'll second the notion that this may be a strong case for a release, considering the number of sites that will likely be affected when updating to 8.7.
Comment #26
rfletcher73 CreditAttribution: rfletcher73 commentedI just encountered this error today. I am using the uswds_base theme. I've created a subtheme. I added the user account menu to a region in my page called "header_user_menu".
My site totally bombs when I add that menu to the block layout. Removing the menu, all is good. I need a block that has the login/logout button.
I'm using the latest version of Drupal Version 8.7.6. I'm new to Drupal.
This looks like the same error, please open this issue:
Comment #27
imclean CreditAttribution: imclean at Digital Ink commented@rfletcher,
This is the Bootstrap issue queue. Create a new issue in the USWDS Base theme issue queue.
This issue is also closed.