Wishlist link adds #attached to lazy builder, throws AssertionError

Created on 7 November 2024, about 2 months ago

Problem/Motivation

When you have assertions enabled and visit a product, this error happens at the moment:

AssertionError: When a #lazy_builder callback is specified, no properties can exist; all properties must be generated by the #lazy_builder callback. You specified the following properties: #attached. in assert() (line 390 of core/lib/Drupal/Core/Render/Renderer.php).

That’s because using BubbleableMetadata in \Drupal\commerce_add_to_wishlist_link\AddToWishlistLink::build() adds attached to that element.

Steps to reproduce

Enable assertions.

Proposed resolution

Remaining tasks

Switching to CacheableMetadata avoids that

I’m not sure if the cacheable metadata on that level is even necessary since you force a a lazy builder anyway. It probably should be inside the lazy buildered part. I would need to dig deeper on that to see if it gets bubbled up.

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡­Switzerland berdir Switzerland

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

Comments & Activities

Production build 0.71.5 2024