Do not do token replacement on objects

Created on 22 February 2022, over 2 years ago
Updated 10 July 2024, about 2 months ago

Problem/Motivation

When a language code is entered in one of the conditions which accept a language, then the rule is triggered we get a runtime error:

Warning: preg_match_all() expects parameter 2 to be string, object given in Drupal\typed_data\PlaceholderResolver->scan()
(line 197 of ___/modules/typed_data/src/PlaceholderResolver.php).

and also

Recoverable fatal error: Object of class Drupal\Core\Language\Language could not be converted to string in Drupal\typed_data\PlaceholderResolver->replacePlaceHolders()
(line 172 of ___/modules/typed_data/src/PlaceholderResolver.php).

Steps to reproduce

Enter a language code, for example 'en', in a condition "Path has Alias". You do not need the language module enabled, as this is only using core functionality

Proposed resolution

The problem is that an object is passed to Typed Data scan function for token replacement, when it is only expecting text. A simple solution is to skip the token replacement if the context variable is an object.

πŸ› Bug report
Status

Needs work

Version

4.0

Component

Rules Core

Created by

πŸ‡¬πŸ‡§United Kingdom jonathan1055

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