Problem/Motivation
Seems like there's an issue with config_translation_overview and contextual links in views. On several pages we get the following error:
Warning: Undefined array key "display_id" in views_ui_contextual_links_view_alter() (Zeile 268 in /web/core/modules/views_ui/views_ui.module). =>
array:34 [▼
"33: views_ui_contextual_links_view_alter()" =>array:2 [▼
"file" => "core/modules/views_ui/views_ui.module:268"
"args" =>array:3 [▼0 =>array:10 [▶]
1 =>array:2 [▼
"entity.view.edit_form" =>array:6 [▶]
"config_translation.contextual_links:entity.view.config_translation_overview" =>array:6 [▼
"route_name" => "entity.view.config_translation_overview"
"route_parameters" =>array:1 [▼
"view" => "birapa_taxonomy_children"
]
"title" =>Drupal\Core\StringTranslation\TranslatableMarkup {#583 ▼
#string: "Translate @type_name"
#arguments: array:1 [▶]
#translatedMarkup: null
#options: []
#stringTranslation: Drupal\Core\StringTranslation\TranslationManager {#119 ▶}
}
"weight" =>100
"localized_options" => []
"metadata" => []
]
]
2 =>null]
]
"32: Drupal\Core\Extension\ModuleHandler->alter()" =>array:2 [▼
"file" => "core/lib/Drupal/Core/Extension/ModuleHandler.php:552"
"args" =>array:3 [▼0 => "contextual_links_view"
1 =>array:10 [▼
"#type" => "contextual_links"
"#contextual_links" =>array:1 [▶]
"#cache" =>array:1 [▶]
"#pre_render" =>array:1 [▶]
"#theme" => "links__contextual"
"#links" =>array:2 [▶]
"#attributes" =>array:1 [▶]
"#attached" =>array:1 [▶]
"#process" =>array:1 [▶]
"#defaults_loaded" =>true]
2 =>array:2 [▼
"entity.view.edit_form" =>array:6 [▶]
"config_translation.contextual_links:entity.view.config_translation_overview" =>array:6 [▶]
]
]
]
"31: Drupal\contextual\Element\ContextualLinks::preRenderLinks()" =>array:2 [▼
"file" => "core/modules/contextual/src/Element/ContextualLinks.php:90"
"args" =>array:1 [▼0 =>array:10 [▼
"#type" => "contextual_links"
"#contextual_links" =>array:1 [▶]
"#cache" =>array:1 [▶]
"#pre_render" =>array:1 [▶]
"#theme" => "links__contextual"
"#links" =>array:2 [▼
"entityviewedit-form" =>array:2 [▶]
"config-translationcontextual-linksentityviewconfig-translation-overview" =>array:2 [▼
"title" =>Drupal\Core\StringTranslation\TranslatableMarkup {#583 ▶}
"url" =>Drupal\Core\Url {#3934 ▼
#urlGenerator: null
#urlAssembler: null
#accessManager: null
#routeName: "entity.view.config_translation_overview"
#routeParameters: array:1 [▶]
#options: []
#external: false
#unrouted: false
#uri: null
#internalPath: null
#_serviceIds: []
#_entityStorages: []
}
]
]
"#attributes" =>array:1 [▼
"class" =>array:1 [▶]
]
"#attached" =>array:1 [▼
"library" =>array:1 [▶]
]
"#process" =>array:1 [▼0 =>array:2 [▼0 => "Drupal\inline_form_errors\RenderElementHelper"
1 => "processElement"
]
]
"#defaults_loaded" =>true]
]
]
"30: call_user_func_array()" =>array:1 [▶]
"29: Drupal\Core\Render\Renderer->doTrustedCallback()" =>array:2 [▶]
"28: Drupal\Core\Render\Renderer->doCallback()" =>array:2 [▶]
"27: Drupal\Core\Render\Renderer->doRender()" =>array:2 [▶]
"26: Drupal\Core\Render\Renderer->render()" =>array:2 [▶]
"25: Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()" =>array:1 [▶]
"24: Drupal\Core\Render\Renderer->executeInRenderContext()" =>array:2 [▶]
"23: Drupal\Core\Render\Renderer->renderRoot()" =>array:2 [▶]
"22: Drupal\contextual\ContextualController->render()" =>array:2 [▶]
"21: call_user_func_array()" =>array:1 [▶]
"20: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()" =>array:1 [▶]
"19: Drupal\Core\Render\Renderer->executeInRenderContext()" =>array:2 [▶]
"18: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()" =>array:2 [▶]
"17: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()" =>array:1 [▶]
"16: Symfony\Component\HttpKernel\HttpKernel->handleRaw()" =>array:2 [▶]
"15: Symfony\Component\HttpKernel\HttpKernel->handle()" =>array:2 [▶]
"14: Drupal\Core\StackMiddleware\Session->handle()" =>array:2 [▶]
"13: Drupal\Core\StackMiddleware\KernelPreHandle->handle()" =>array:2 [▶]
"12: Drupal\Core\StackMiddleware\ContentLength->handle()" =>array:2 [▶]
"11: Drupal\page_cache\StackMiddleware\PageCache->pass()" =>array:2 [▶]
"10: Drupal\page_cache\StackMiddleware\PageCache->handle()" =>array:2 [▶]
"\u{A0}9: Drupal\ban\BanMiddleware->handle()" =>array:2 [▶]
"\u{A0}8: Drupal\shield\ShieldMiddleware->bypass()" =>array:2 [▶]
"\u{A0}7: Drupal\shield\ShieldMiddleware->handle()" =>array:2 [▶]
"\u{A0}6: Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()" =>array:2 [▶]
"\u{A0}5: Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()" =>array:2 [▶]
"\u{A0}4: Drupal\Core\StackMiddleware\AjaxPageState->handle()" =>array:2 [▶]
"\u{A0}3: Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle()" =>array:2 [▶]
"\u{A0}2: Drupal\Core\StackMiddleware\StackedHttpKernel->handle()" =>array:2 [▶]
"\u{A0}1: Drupal\Core\DrupalKernel->handle()" =>array:2 [▶]
"\u{A0}0: main()" =>array:2 [▶]
]
See that metadata is empty!
This is where it happens:
/**
* Implements hook_contextual_links_view_alter().
*/
function views_ui_contextual_links_view_alter(&$element, $items) {
// Remove contextual links from being rendered, when so desired, such as
// within a View preview.
if (views_ui_contextual_links_suppress()) {
$element['#links'] = [];
}
// Append the display ID to the Views UI edit links, so that clicking on the
// contextual link takes you directly to the correct display tab on the edit
// screen.
elseif (!empty($element['#links']['entityviewedit-form'])) {
$display_id = $items['entity.view.edit_form']['metadata']['display_id'];
$route_parameters = $element['#links']['entityviewedit-form']['url']->getRouteParameters() + ['display_id' => $display_id];
$element['#links']['entityviewedit-form']['url'] = Url::fromRoute('entity.view.edit_display_form', $route_parameters);
}
}
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3474093
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 11.x
changes, plain diff MR !9489
- 3474093-warning-undefined-array
compare
Comments
Comment #2
anybodyComment #6
anybodyComment #7
anybodyAs the backtrace shows, there are cases where metadata is empty, so let's better check if the value exists.
Comment #8
anybodyComment #9
smustgrave commentedThink we need to figure out the metadata is empty. Make sure we aren't masking a larger issue.
But can findings be added to the issue summary too.