Problem/Motivation
I get on-screen PHP warnings when loading a full node page that contains a layout canvas with a preexisting component that was updated from the old block-based views block approach to the new views_element based approach.
It makes sense that the component would not render a view until an admin goes to update the component and apply changes after picking the right view, but it is unexpected that the component would give a php warning when the component is not correctly configured and is missing the new field token.
Warning: Undefined array key 1 in Drupal\site_studio_views_element\Plugin\CustomElement\ViewsElement->render() (line 72 of modules/contrib/site_studio_views_element/src/Plugin/CustomElement/ViewsElement.php).
Drupal\site_studio_views_element\Plugin\CustomElement\ViewsElement->render(Array, NULL, 'coh-ce-cpt_articles_slider-f977a1be', Array, Object) (Line: 613)
Full stack trace:
Drupal\site_studio_views_element\Plugin\CustomElement\ViewsElement->render(Array, NULL, 'coh-ce-cpt_articles_slider-f977a1be', Array, Object) (Line: 613)
Drupal\cohesion_elements\CustomElementsService->render(Array, NULL, 'coh-ce-cpt_articles_slider-f977a1be', Array, Object) (Line: 1764)
Drupal\cohesion_templates\TwigExtension\TwigExtension->customElement('{"element":"site_studio_views_element","title":"Drupal View","view_id":false}', 'null', 'coh-ce-cpt_articles_slider-f977a1be', '{"contextAttributes":{{}}}', Object) (Line: 81)
__TwigTemplate_ae8938af538128f4ca563fe77812a002->doDisplay(Array, Array) (Line: 394)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
Twig\Template->display(Array) (Line: 379)
Twig\Template->render(Array, Array) (Line: 40)
Twig\TemplateWrapper->render(Array) (Line: 53)
twig_render_template('sites/fsos/files/cohesion/templates/component--cohesion-cpt-articles-slider.html.twig', Array) (Line: 372)
Drupal\Core\Theme\ThemeManager->render('component__cohesion_cpt_articles_slider', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 477)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 1313)
__TwigTemplate_9b303454c59e55d66c91a8de669d37de->block_block939101174(Array, Array) (Line: 171)
Twig\Template->displayBlock('block939101174', Array, Array) (Line: 1055)
__TwigTemplate_9b303454c59e55d66c91a8de669d37de->block_block1908210186(Array, Array) (Line: 171)
Twig\Template->displayBlock('block1908210186', Array, Array) (Line: 591)
__TwigTemplate_9b303454c59e55d66c91a8de669d37de->doDisplay(Array, Array) (Line: 394)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
Twig\Template->display(Array) (Line: 379)
Twig\Template->render(Array, Array) (Line: 40)
Twig\TemplateWrapper->render(Array) (Line: 234)
Drupal\Core\Template\TwigEnvironment->renderInline(' ... site studio twig template for the component here ...')
Proposed resolution
Ensure view render is only executed if all the required parameters are present from the component config. Gracefully fail if no view is selected.
Remaining tasks
Write a patch
User interface changes
na
API changes
na
Data model changes
na