Attribute should be Attribute class object or array

Created on 18 November 2021, about 3 years ago
Updated 15 May 2023, over 1 year ago

Problem/Motivation

If we pass the invalid plugin_id then menus_attribute function returns NULL as attribute and it logs Warning in Drupal log.

Warning: assert(): $attributes, if set, must be an array or object of type \Drupal\Core\Template\Attribute failed in Drupal\Core\Template\TwigExtension->getLink() (line 234 of /app/docroot/core/lib/Drupal/Core/Template/TwigExtension.php)
#0 /app/docroot/core/includes/bootstrap.inc(312): _drupal_error_handler_real(2, 'assert(): $attr...', '/app/docroot/co...', 234)
#1 [internal function]: _drupal_error_handler(2, 'assert(): $attr...', '/app/docroot/co...', 234, Array)
#2 /app/docroot/core/lib/Drupal/Core/Template/TwigExtension.php(234): assert(false, '$attributes, if...')

Steps to reproduce

call menus_attribute method in twig and pass third parameter as invalid plugin id.

Proposed resolution

We need to pass Attribute class object as return value.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇳India iyyappan.govind Chennai, India

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