Error "Non-reusable blocks must set an access dependency for access control." with layout builder and media library

Created on 23 April 2024, 8 months ago

Problem/Motivation

In d10.2.5 editing a block with layout builder and the media library widget in existing blocks I have the following error when trying to add a Media or select an existing one:

message: '\nAn AJAX HTTP error occurred.\nHTTP Result Code: 403\nDebugging information follows.\nPath: /media-library?destination=/node/8/layout&_wrapper_format=drupal_ajax&ajax_form=1&media_library_opener_id=media_library.opener.field_widget&media_library_allowed_types%5Bimage%5D=image&media_library_selected_type=image&media_library_remaining=1&media_library_opener_parameters%5Bfield_widget_id%5D=field_hc_image%3A-settings-block_form&media_library_opener_parameters%5Bentity_type_id%5D=block_content&media_library_opener_parameters%5Bbundle%5D=hotel_counters&media_library_opener_parameters%5Bfield_name%5D=field_hc_image&media_library_opener_parameters%5Bentity_id%5D=3329&media_library_opener_parameters%5Brevision_id%5D=28621&hash=R00G-VI2Jd-tylep7AkBs4y4KjJiYQYYbDpLcDZsRXk&views_display_id=widget\nStatusText: Forbidden\nResponseText: {"message":"Non-reusable blocks must set an access dependency for access control."}'
​
name: "AjaxError"
​
stack: "@http://localhost:8080/core/misc/ajax.js?v=10.2.5:196:32\n@http://localhost:8080/core/misc/ajax.js?v=10.2.5:1916:3\n"

Without creating a new block it doesn't happen. Can somebody help me?
I see that this error message comes from the checkAccess function in core/modules/block_content/src/BlockContentAccessControlHandler.php

Steps to reproduce

1. Enable Layout Builder
2. Install Media and Media library module
3. Add a Media reference (Image bundle) and use Media library form widget to the block type
4. In existing node try to edit a custom block and upload a media or select an existing one.

πŸ› Bug report
Status

Active

Version

10.2 ✨

Component
MediaΒ  β†’

Last updated about 22 hours ago

Created by

πŸ‡¨πŸ‡ΊCuba ccolumbie

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

Comments & Activities

  • Issue created by @ccolumbie
  • i have the same problem after upgrade Drupal to drupal 10 and group from 1.6 to group 2.

  • πŸ‡―πŸ‡΄Jordan Rajab Natshah Jordan

    Facing the same error in media items in custom inline blocks with the Layout Builder

  • I had the same problem when I tried with Layout builder to add a media in an inline block.
    To solve this problem, activate the checkbox β€œCreate new revisions” in the block type, and then I updated all the inline blocks to create a revision for each one.

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    This needs to be fixed on 11.x (main) first and 10.2 is receiving only security fixes now.

  • πŸ‡¨πŸ‡·Costa Rica esolano

    I believe the issue is that Content Blocks can have revisions turned off on a per bundle (type) basis. When this is the case, the access dependency fails to work properly in `getInlineBlockDependency` , since it tries to work on the latest revision only.

    This patch might be helpful. I hope it helps.

Production build 0.71.5 2024