Sometimes NULL values are sent to Core's Token replacement service causing PHP8 notice

Created on 11 November 2022, over 2 years ago
Updated 23 July 2025, 6 days ago

Problem/Motivation

preg_match_all in \Drupal\Core\Utility\Token::scan() now requires that the text to scan is not NULL. Sometimes token_default_tokens_alter() passes a NULL value.

Steps to reproduce

1. content type A has entity reference field to content type B
2. use token in metatag module to output [field_reference_example:entity:url] from content type A
3. open example of content type A where reference field is empty
4. error shown

Proposed resolution

Don't pass NULL values.

Remaining tasks

Patching coming shortly

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom scott_euser

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