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

Issue fork drupal-3445184

Command icon 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

matthieuscarset created an issue. See original summary.

matthieuscarset’s picture

Status: Active » Needs review
skaught’s picture

Status: Needs review » Reviewed & tested by the community

have tested branch. attached mov of profile and enabling of Navigation.
works as expected!

smustgrave’s picture

Will 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.

catch’s picture

Status: Reviewed & tested by the community » Needs work

Navigation 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.

skaught’s picture

thanks @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?

catch’s picture

moreover, Shortcuts should install into navigation now that it's in core?

Not yet, but the logic could switch over once navigation is stable.

plopesc’s picture

Thank 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:

  1. Try to find why blockAccess() is not being invoked and try to invoke it even for the LB config page
  2. Add an extra check in NavigatioShortcutsBlock::build() to ensure that Shortcut module is enabled
  3. Continue adding shortcut as a navigation dependency. If so, I would remove all the code checking if Shortcut module is enabled

From my perspective, I would avoid the 3rd option because that would add an unnecessary dependency for the future.

larowlan’s picture

Agree 3 feels like the worst option

plopesc’s picture

skaught’s picture

catch’s picture

Add an extra check in NavigatioShortcutsBlock::build() to ensure that Shortcut module is enabled

This 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.

ckrina’s picture

Issue tags: +Portland2024

m4olivei made their first commit to this issue’s fork.

m4olivei’s picture

Status: Needs work » Needs review

Opened 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.

smustgrave’s picture

Status: Needs review » Needs work

Agree 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.

plopesc’s picture

Status: Needs work » Needs review

Tests added to MR !7944

smustgrave changed the visibility of the branch 3445184-fatal-error-when to hidden.

skaught’s picture

Status: Needs review » Needs work

Using 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.

plopesc’s picture

Status: Needs work » Needs review

Thank 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!

skaught’s picture

Status: Needs review » Reviewed & tested by the community
Related issues: +#3447907: Navigation glitch with Shortcuts and Minimal Profile
StatusFileSize
new22.39 MB

Certainly!
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.

  • catch committed c89af852 on 10.3.x
    Issue #3445184 by plopesc, matthieuscarset, m4olivei: Fatal error when...

  • catch committed a81b9fc4 on 10.4.x
    Issue #3445184 by plopesc, matthieuscarset, m4olivei: Fatal error when...

  • catch committed 932ef94e on 11.0.x
    Issue #3445184 by plopesc, matthieuscarset, m4olivei: Fatal error when...

  • catch committed e96135b2 on 11.x
    Issue #3445184 by plopesc, matthieuscarset, m4olivei: Fatal error when...
catch’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x and cherry-picked to 11.0.x/10.4.x/10.3.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.