Tokens for rules variables with value 0 (zero) are replaced with empty string

Created on 11 September 2013, over 11 years ago
Updated 27 June 2023, almost 2 years ago

This one is easy to reproduce by creating a rules variable with an integer value of 0 (zero), then try to display a system message using its value from its token. The message will have the token replaced by an empty string rather than a string representation of the zero.

This is because rules_tokens() only provides replacements if !empty($data[$type]) -- and integer 0, float 0.0, and even string containing '0' all count as "empty".

Would there be harm in changing this logic? My initial reaction is to replace the call to empty() with a call to isset().

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Rules Core

Created by

πŸ‡ΊπŸ‡ΈUnited States Josh Benner

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