Allow numeric to be tampered in FindReplace & sprintf functions

Created on 11 September 2020, over 4 years ago
Updated 21 February 2024, 11 months ago

Problem/Motivation

Find/Replace functions have a test to verify that the data is a string before acting on it. However when you try to parse an ID inside a feed and match it to a taxonomy term, the integer data will return an error "Input should be a string".

Steps to reproduce

Try to add a plugin FindReplace to a JSON feed with integer ID to match an existing taxonomy term name.

"category": {
  "id": 123,
  "label": "Feed category name "
},

So here we would like to replace 123 by our existing Taxonomy term "Website category A" so the match can be done whenever the label in the field would change.

Proposed resolution

Make a broader test to include numerics for those tests :

    if (!is_string($data)) {
      throw new TamperException('Input should be a string.');
    }

Also should booleans be allowed too ?

Remaining tasks

Patch to review

User interface changes

None

API changes

None

Data model changes

None

Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

🇫🇷France tostinni

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.

  • 🇵🇹Portugal jrochate

    Actually I had to add a check for boolean value in order to work.

    Something like the patch below, applied after the above commit.

    Tamper was sending an error message on line 100, FindReplace, because of a value of "true" that wasn't numeric nor string.

Production build 0.71.5 2024