Fatal error when accessing Navigation Blocks on a minimal profile installation because of the Shortcut block

Created on 3 May 2024, 15 days ago
Updated 17 May 2024, about 16 hours ago

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

πŸ› Bug report
Status

RTBC

Version

11.0 πŸ”₯

Component
NavigationΒ  β†’

Last updated less than a minute ago

No maintainer
Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @matthieuscarset
  • Status changed to Needs review 15 days ago
  • Status changed to RTBC 15 days ago
  • πŸ‡¨πŸ‡¦Canada SKAUGHT

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

  • Pipeline finished with Success
    15 days ago
    Total: 759s
    #163833
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    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.

  • Status changed to Needs work 15 days ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    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.

  • πŸ‡¨πŸ‡¦Canada SKAUGHT

    thanks @catch
    A good thought around keeping a 'softer dependency' this way.

  • πŸ‡¬πŸ‡§United Kingdom catch
    moreover, Shortcuts should install into navigation now that it's in core?

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

  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

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

  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Agree 3 feels like the worst option

  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

    Created πŸ› BlockComponentRenderArray::onBuildRender() does not check block access in Preview mode Active

    To try to address the LB preview issue.

    If that gets in, this one could be closed.

  • πŸ‡¨πŸ‡¦Canada SKAUGHT

    Thanks, i see that aspect too.

    πŸ› In a Drupal site with low resource use (minimal profile) Navigations 'Create section' is missing key items. Active had just noticed some other similar dependency calls working a bit strangely still.

  • πŸ‡¬πŸ‡§United Kingdom catch

    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.

  • πŸ‡ͺπŸ‡ΈSpain ckrina Barcelona
  • First commit to issue fork.
  • Status changed to Needs review 11 days ago
  • πŸ‡¨πŸ‡¦Canada m4olivei Grimsby, ON

    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.

  • Pipeline finished with Failed
    11 days ago
    Total: 1024s
    #166552
  • Pipeline finished with Success
    11 days ago
    Total: 757s
    #166756
  • Status changed to Needs work 10 days ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    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.

  • Pipeline finished with Failed
    about 20 hours ago
    Total: 165s
    #175205
  • Status changed to Needs review about 20 hours ago
  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

    Tests added to MR !7944

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

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

  • Pipeline finished with Success
    about 18 hours ago
    Total: 9468s
    #175222
  • Status changed to Needs work about 17 hours ago
  • πŸ‡¨πŸ‡¦Canada SKAUGHT

    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. does not "(star) shortcuts" item to 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.

  • Status changed to Needs review about 17 hours ago
  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

    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!

  • Status changed to RTBC about 16 hours ago
  • πŸ‡¨πŸ‡¦Canada SKAUGHT

    Certainly!
    It is true, unless I add an item the main branch item doesn't appear.

    πŸ› Navigation glitch with Shortcuts and Minimal Profile Active have opened for followup.

Production build 0.67.2 2024