Copy tab link array is missing localized_options key

Created on 16 July 2024, 4 months ago

Problem/Motivation

Apparently it a "localized_options" array is required in the "#link" sub array of a local task tab. If you don't have it, you can get an "TypeError: Unsupported operand types: array + null" error.

Though, this might be specific to some themes. I figured it out via: https://www.drupal.org/project/bootstrap_barrio/issues/3280356#comment-1... β†’

This is the full error:

The website encountered an unexpected error. Try again later.

TypeError: Unsupported operand types: array + null in bootstrap_barrio_preprocess_menu_local_task() (line 552 of themes/contrib/bootstrap_barrio/bootstrap_barrio.theme).

call_user_func_array() (Line: 261)
Drupal\Core\Theme\ThemeManager->render() (Line: 491)
Drupal\Core\Render\Renderer->doRender() (Line: 504)
Drupal\Core\Render\Renderer->doRender() (Line: 248)
Drupal\Core\Render\Renderer->render() (Line: 475)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 61)
__TwigTemplate_53e7f1b75adfcb0e49fe5eda2fce1484->doDisplay() (Line: 360)
Twig\Template->yield() (Line: 335)
Twig\Template->render() (Line: 38)
Twig\TemplateWrapper->render() (Line: 33)
twig_render_template() (Line: 348)
Drupal\Core\Theme\ThemeManager->render() (Line: 491)
Drupal\Core\Render\Renderer->doRender() (Line: 248)
Drupal\Core\Render\Renderer->render() (Line: 475)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 58)
__TwigTemplate_28b923a03e7eb51bc594b820c6e56ecf->block_content() (Line: 430)
Twig\Template->yieldBlock() (Line: 41)
__TwigTemplate_28b923a03e7eb51bc594b820c6e56ecf->doDisplay() (Line: 360)
Twig\Template->yield() (Line: 335)
Twig\Template->render() (Line: 38)
Twig\TemplateWrapper->render() (Line: 33)
twig_render_template() (Line: 348)
Drupal\Core\Theme\ThemeManager->render() (Line: 491)
Drupal\Core\Render\Renderer->doRender() (Line: 504)
Drupal\Core\Render\Renderer->doRender() (Line: 248)
Drupal\Core\Render\Renderer->render() (Line: 475)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 348)
__TwigTemplate_0f5cfecd63950800155aa64a8e4fae9f->block_content() (Line: 430)
Twig\Template->yieldBlock() (Line: 85)
__TwigTemplate_0f5cfecd63950800155aa64a8e4fae9f->doDisplay() (Line: 360)
Twig\Template->yield() (Line: 335)
Twig\Template->render() (Line: 38)
Twig\TemplateWrapper->render() (Line: 33)
twig_render_template() (Line: 348)
Drupal\Core\Theme\ThemeManager->render() (Line: 491)
Drupal\Core\Render\Renderer->doRender() (Line: 248)
Drupal\Core\Render\Renderer->render() (Line: 475)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 85)
__TwigTemplate_4311a4d2488bd5faba6dbc83e887aecb->doDisplay() (Line: 360)
Twig\Template->yield() (Line: 335)
Twig\Template->render() (Line: 38)
Twig\TemplateWrapper->render() (Line: 33)
twig_render_template() (Line: 348)
Drupal\Core\Theme\ThemeManager->render() (Line: 491)
Drupal\Core\Render\Renderer->doRender() (Line: 248)
Drupal\Core\Render\Renderer->render() (Line: 158)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 153)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
call_user_func() (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)

I actually ran into this a while back and thought it had been fixed here: https://www.drupal.org/project/entity_copy_reference/issues/3347826 πŸ› all admin-structure menus(Content Types, Taxo, Menu, Views, etc) are inaccessible after activating entity_copy_reference module Needs review But I'm guessing the "localized_options" part of my patch didn't get merged.

Steps to reproduce

Visit a node that has the copy local task tab.

Proposed resolution

Add an empty array with the key "localized_options" to the copy tab menu array's "#link" array.

Remaining tasks

Implement the fix.

Attached is a patch file that works on my site. I haven't done any other testing. But it shows where the array needs to go.

Oh, and I think I originally was on Drupal 8 or 9 when I first ran into this. This time around I had to upgrade cweagans/composer-patches to the 2.x dev version before composer could apply the patch for me.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jerrac

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

Comments & Activities

Production build 0.71.5 2024