Failure to add blocks to categories when default language is not english

Created on 24 September 2023, over 1 year ago

Problem/Motivation

On a site where the default (admin) language is not english, when trying to add blocks to block categories, the block form fails to load.

Steps to reproduce

  1. Have a site with default language other that english
  2. Start with new Layout Builder Browser setup
  3. Add a block category
  4. Try to add a block to the category

Proposed resolution

From the logs,

Warning: Undefined array key "" in Drupal\layout_builder_browser\Form\BlockForm->form() (line 101 of /var/www/html/web/modules/contrib/layout_builder_browser/src/Form/BlockForm.php) 

an empty $provider value turns out to be the problem, because

  1. block categories can/are translated and the first default value is an untranslated english name ('Inline blocks')
  2. the last fallback logic is incorrect (empty check on $block_provider_map to fetch item from that array

Remaining tasks

Fix.

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇧🇪Belgium andreasderijcke Antwerpen / Gent

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

Comments & Activities

  • Issue created by @andreasderijcke
  • @andreasderijcke opened merge request.
  • 🇧🇪Belgium andreasderijcke Antwerpen / Gent

    Merge request added:

    1. Running the 'Inline blocks' for default value determination through translation fixes the main problem, for both english or other language as default language.
    2. Fixed the last fallback check + it is not the key of a $block_provider_map item, but the value that holds the category id/label that is being used as provider.
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇧🇪Belgium andreasderijcke Antwerpen / Gent
Production build 0.71.5 2024