Data processors do not check type before performing type-specific operations

Created on 5 February 2017, over 8 years ago
Updated 21 July 2024, over 1 year ago

The "rules_tokens" and "rules_numeric_offset" RulesDataProcessors do not check the type of $value before performing type-specific operations.

This can lead to errors when $value is an Object, for example when the "Language" condition is used. To see this, add the "Language" condition to any Rule, then trigger that rule. You should see the fatal error "Recoverable fatal error: Object of class Drupal\Core\Language\Language could not be converted to string in Drupal\typed_data\PlaceholderResolver->replacePlaceHolders()".

The proposed patch adds type checking to the two default data processors Rules provides, which aligns made sense as the documentation for \Drupal\rules\Context\DataProcessorInterface::process says that $value is mixed.

πŸ› Bug report
Status

Needs review

Version

4.0

Component

Rules Core

Created by

πŸ‡ΊπŸ‡ΈUnited States samuel.mortenson

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

Merge Requests

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