Array to string conversion in Token.php

Created on 4 October 2024, 6 months ago

Problem/Motivation

Warning: Array to string conversion in Drupal\Core\Utility\Token->replace() (line 194 of /web/core/lib/Drupal/Core/Utility/Token.php)

Following changes to add a link to 'title', I tried to use the 'custom' destination option and caused/experienced. All with Layout Builder.

- Token got an array rather than the token name
- Destination had Array prepended to it each time I saved the settings form.

Steps to reproduce

- Use Layout Builder on the display
- Add a title block
- Link this field
- Use a custom destination. [node:field_article_link:uri]

Proposed resolution

Refer to the included changes. I extracted some variables to avoid duplicate variable names, and changed the href regex to use the href utility. I didn't see any href embedded in token text as I was using a link field.

The embedded array is caused by nested content in the 'settings' variable.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇦🇺Australia interlated

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

Comments & Activities

Production build 0.71.5 2024