Problem/Motivation
Having both core Navigation module and contrib Modifiers module enabled causes an error.
The change in #3443810: Custom Navigation logo is disconnected from new Layout template introduced a 'settings' array without a preceding '#'. When the Modifiers module attempts to process this array in a template_preprocess_layout() function it causes an error in Element::children() as settings is not a valid render array.
Steps to reproduce
- Enable Modifiers module
- Enable Navigation module
- Observe error:
InvalidArgumentException: "hide_logo" is an invalid render array key. Value should be an array but got a boolean. in Drupal\Core\Render\Element::children() (line 102 of core/lib/Drupal/Core/Render/Element.php).
Proposed resolution
I think the output of doBuildNavigation() should be a valid render array so properties such as 'settings' should have a '#' to indicate they are not intended to be rendered directly.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | default_logo.png | 627.14 KB | m4olivei |
| #9 | hide_logo.png | 621.09 KB | m4olivei |
| #9 | custom_logo.png | 983.23 KB | m4olivei |
Issue fork drupal-3516558
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3516558-backport
changes, plain diff MR !12181
- 3516558-settings-is-not-render-array
changes, plain diff MR !11696
Comments
Comment #2
tarawij commentedI can reproduce this on Drupal core 10.4.5, 11.0.13, and 11.1.5 with Modifiers 8.x-1.6.
Comment #5
plopescThe suggestion looks valid to me.
Changed settings to #settings and I didn't detect any regression afterwards.
Comment #6
smustgrave commentedSeems straight forward, been told since navigation is experimental then a CR isn't needed. Also believe this qualifies for not needing test coverage
Comment #7
m4oliveiAs
#settingsis defined by Layout Builder for layout templates, we can actually simplify its use in the template. See MR for details.Comment #8
plopescThank you for your review @m4olivei. Great catch!
Addressed your comments in the last commit.
Comment #9
m4oliveiLooks great! Thanks for this @plopesc.
I'm seeing everything look good including adjusting the logo settings, eg.
Hide Logo:
Default logo:
Custom logo
Comment #11
pdureau commentedCommitted 05057f1 and pushed to 11.x. Thanks!
Need to be ported to 11.1.x, 10.5.x & 10.4.x (careful, 10.5.x has a merge conflict)
Comment #14
nod_doesn't cherry pick to 10.5.x, need a MR for that one
Comment #15
nod_Comment #17
smustgrave commentedSeems to be a clean backport
Comment #20
nod_Committed and pushed 34f55547a4e to 10.6.x and 7d1886dab79 to 10.5.x. Thanks!