Do not do token replacement on objects

Created on 22 February 2022, over 2 years ago
Updated 10 July 2024, 8 days ago


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

Needs work




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 some issue and comment data are missing.

Production build 0.69.0 2024