Problem/Motivation
After an fresh install of Drupal 11 with a minimal installation profile, there is a fatal error on the Navigation block settings page (see capture). This is caused by a missing dependency to drupal:shortcut. The nav block \Drupal\navigation\Plugin\Block\NavigationShortcutsBlock depends on it.

Steps to reproduce
* Install a fresh Drupal 11
* Enable navigation module
* Go to Admin > Config > User interface > Navigation blocks
* Result: WSOD.
Proposed resolution
* Quick fix: Add the missing dependency to shortcut in the info file.
* Long term fix: TBD
Remaining tasks
* Quick fix: review and merge attached MR
* Long term fix: TBD
| Comment | File | Size | Author |
|---|---|---|---|
| Screenshot from 2024-05-03 21-18-59.png | 290.01 KB | matthieuscarset |
Issue fork drupal-3445184
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:
Comments
Comment #3
matthieuscarset commentedComment #4
skaughthave tested branch. attached mov of profile and enabling of Navigation.
works as expected!
Comment #5
smustgrave commentedWill leave it in RTBC but don’t think shortcut should be a hard dependency. A lot of sites don’t use shortcuts. Think navigation should handle if shortcuts isn’t installed.
Comment #6
catchNavigation module could add the shortcuts block to its own configuration in a hook_modules_installed() and then remove it again in hook_modules_uninstalled(). I think that can probably be done here.
Comment #7
skaughtthanks @catch
A good thought around keeping a 'softer dependency' this way. I've been working with some this a as general concern as Navigation 'needs more'.
yes, what are have in 'navigation.block_layout.yml' should be installed if related modules are enabled. moreover, Shortcuts should install into navigation now that it's in core?
Comment #8
catchNot yet, but the logic could switch over once navigation is stable.
Comment #9
plopescThank you for your work on this.
The root source of this issue is that in LB managing page, apparently
NavigatioShortcutsBlock::blockAccess()method is not being invoked.That method checks whether shortcuts module is enabled or not before continuing.
Form this point I think we have some alternatives:
From my perspective, I would avoid the 3rd option because that would add an unnecessary dependency for the future.
Comment #10
larowlanAgree 3 feels like the worst option
Comment #11
plopescCreated #3445369: BlockComponentRenderArray::onBuildRender() does not check block access in Preview mode to try to address the LB preview issue.
If that gets in, this one could be closed.
Comment #12
skaughtThanks, i see that aspect too.
#3445488: In a Drupal site with low resource use (minimal profile) Navigations 'Create section' is missing key items. had just noticed some other similar dependency calls working a bit strangely still.
Comment #13
catchThis is probably a good idea for a quick fix to stop the fatal error. Can then figure out better how optional support from different modules should be added.
A question for me is if a module wants to add itself to the toolbar on install, and not just as a menu link, should it be able to do that? If so, then implementing that in shortcut module would provide an example.
Comment #14
ckrinaComment #17
m4oliveiOpened an alternative approach in MR 7944 which simply returns an empty render array when shortcuts module is not enabled. This avoids the fatal error. Eventually when we can move this logic into shortcuts module, it won't be necesssary.
Comment #18
smustgrave commentedAgree with the test suggestion by @larowlan. See there is already ShortcutsNavigationBlockTest with a very extensive test in there. Wonder if at the very end could just uninstall shortcut and do some simple assertions everything is fine.
Comment #19
plopescTests added to MR !7944
Comment #21
skaughtUsing new branch 3445184-fatal-error-when-alternative
After installing Minimal profile, then going to admin/extend to enable Navigation (alone) it is initializing without error. As we did not enable Shortcuts the item is not there (so far as expected!).
-next, enable shortcuts module. notice: no "(star) shortcuts" appears at top of all others.
- clear cache. "(star) shortcuts" does not appear.
-next step to try: disable navigation. LEAVE Shortcuts ENABLED!.
- clear caches.
- re-enable navigation. still no "(star) Shortcuts" item.
---
meanwhile: reinitialize env -- install regular standard profile, then enable navigation -- "(star) shortcuts" is working as expected.
This could be a follow-up issue knowing this is only handling the 'major' aspect with this ticket.
Comment #22
plopescThank you for your review!
I think the scenario described in your manual test is missing the step to create shortcut links.
When there are no shortcut links to show to the user, the shortcuts navigation block is not rendered.
According to https://git.drupalcode.org/project/drupal/-/blob/11.x/core/profiles/stan.... Standard profile creates some shortcut links by default during installation.
It is possible that this is not happening in minimal, where you need to create some shortcut links by yourself to have access to the shortcuts block.
Could you please repeat your tests and confirm this?
Thank you!
Comment #23
skaughtCertainly!
It is true, unless I add an item the main branch for shortcuts items doesn't appear.
#3447907: Navigation glitch with Shortcuts and Minimal Profile have opened for followup.
Comment #28
catchCommitted/pushed to 11.x and cherry-picked to 11.0.x/10.4.x/10.3.x, thanks!