Undefined array key for non-reusable blocks

Created on 19 September 2023, 9 months ago
Updated 16 May 2024, about 1 month ago

Problem/Motivation

Steps to reproduce

To use reusable, non-reusable custom blocks

Proposed resolution

Add additional check if such block exists.

We have reusable and non-reusable custom blocks. In /layout_builder_restrictions/src/Plugin/LayoutBuilderRestriction/EntityViewModeRestriction.php file function alterBlockDefinitions () there is a code $delta = $content_block_types_by_uuid[$uuid]; '$uuid' takes value from $definitions whole list of block without reusable restriction, and '$content_block_types_uuid' is taken from $this->getBlockTypeByUuid() where there is a restriction by 'block_content_field_data' reusable value. So we get underfined array key error.

🐛 Bug report
Status

Postponed: needs info

Version

3.0

Component

Code

Created by

🇺🇦Ukraine yugro Lutsk

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

Merge Requests

Comments & Activities

  • Issue created by @yugro
  • Assigned to Shreya_98
  • Issue was unassigned.
  • Status changed to Needs review 9 months ago
  • 🇮🇳India shiv_yadav

    Hello yugro, I have followed given reproduced step but not got any error so please provide proper reproduced step as well.
    my configuration drupal -9.5.10

  • 🇺🇦Ukraine yugro Lutsk

    Hello shiv_yadav, I think I found the issue, it was that we had reusable value == 0 in block_content_field_data table and such blocks were cropped by getBlockTypeByUuid() function in EntityViewModeRestriction.php. Though in the same file there is an expression $delta = $content_block_types_by_uuid[$uuid]; , where $uuid includes all blocks in DB and $content_block_types_by_uuid includes only those with reusable==1. I have updated DB for the value and it works. But perhaps it would be good to have check if $uuid is in_array();

  • 🇮🇳India shiv_yadav

    Hello @yugro,
    As i have made changes as per your requirements in the code in file EntityViewModeRestriction.php . Also created MR for this . Kindly review the changes .

    Thank you.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 9 months ago
    18 pass, 4 fail
  • 🇺🇦Ukraine yugro Lutsk

    Hi @shiv_yadav,
    Unfortunately I am not a maintainer or the module to review MR.

  • 🇮🇳India shiv_yadav

    Thanks for responding, take clone this MR on local. verify your issue.it's fixed or not.

  • 🇺🇸United States mark_fullmer Tucson
  • 🇺🇸United States daddison

    I might have been unclear on the steps to reproduce. I enabled layout builder and layout builder restrictions for basic page on vanilla Drupal 10.1.5. I added one reusable and one inline Basic block to a node. Then I created a custom block type and added one reusable and one inline instance of the custom block to the node. I could not reproduce the error.

  • Status changed to Postponed: needs info 7 months ago
  • 🇺🇸United States mark_fullmer Tucson

    Based on the comment in #10 above, I'm going to mark this as "Postponed (Maintainer needs more info)." We need specific steps to reproduce. Thanks!

Production build 0.69.0 2024