incompatibility with layout_builder_st, contextual links broken

Created on 5 May 2020, over 4 years ago
Updated 18 May 2023, over 1 year ago

Problem/Motivation

I have layout_builder_modal with layout_builder_st installed.

When I tried to translate a block and got following Error Message:

TypeError: Argument 1 passed to Drupal\Component\Utility\UrlHelper::buildQuery() must be of the type array, null given, called in /var/www/html/drupal/core/modules/contextual/contextual.module on line 180 in Drupal\Component\Utility\UrlHelper::buildQuery() (line 42 of /var/www/html/drupal/core/lib/Drupal/Component/Utility/UrlHelper.php) #0 /var/www/html/drupal/core/modules/contextual/contextual.module(180): Drupal\Component\Utility\UrlHelper::buildQuery(NULL)

The LayoutBuilderModal.php just adds metadata to a fixed array element and won't check if this array element is set or not.

$section_child_element['#contextual_links']['layout_builder_block']['metadata']['layout_builder_modal'] = $hash;

layout_builder_st creates three different types of contextual link groups.

  • layout_builder_block_translation
  • layout_builder_inline_block_translation
  • layout_builder_block

Proposed resolution

Before the hash value is set to the contextual link element search for elements start with `layout_builder_`. Add the value to the first element and don't create a new contextual link, just with metadata.

In `layout_builder_modal_contextual_links_alter` a check was added to the `layout_builder_st` link elements.
In `layout_builder_modal_link_alter` a check was added for the `layout_builder_st` translation routes.

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany Fabian Boensch

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024