Tamper plugin conditions return value instead of boolean

Created on 10 April 2023, about 1 year ago

Problem/Motivation

All tamper plugins are being made available both as actions and as conditions. However, the tamper plugins do not return boolean values. E.g. FindReplaceRegex returns the un(changed) value or null, if there was an error. When used as ECA condition, it would be helpful to return a boolean value.

Steps to reproduce

Create an ECA model with a FindReplaceRegex tamper condition that replaces a part of a string. It always returns a value, which results in true for the condition.

✨ Feature request
Status

Closed: works as designed

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡­Switzerland boromino

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

Comments & Activities

  • Issue created by @boromino
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Well, those conditions are an extension of the "Compare 2 arbitrary values" condition. That means, the eca_tamper conditions compare the original and the tampered value with each other. That happens in \Drupal\eca_tamper\Plugin\ECA\Condition\Tamper::getLeftValue and \Drupal\eca_tamper\Plugin\ECA\Condition\Tamper::getRightValue. The right value is the original one and the left value is the tampered value. The comparison then happens in \Drupal\eca\Plugin\ECA\Condition\StringComparisonBase::evaluate and that return TRUE or FALSE already.

    So, this works as designed.

    However, there is one special case when the tampering responds with an exception while determining the left value. In that case, we currently set the left value to the same as the original one, assuming that if the tampering isn't working, then the value doesn't get tampered.

    Question: are you only seeing this problem if the regex runs into an error?

  • Status changed to Closed: works as designed about 1 year ago
  • πŸ‡¨πŸ‡­Switzerland boromino

    Thanks for the explanation, that helped me to find the error. My mistake was that I had left "Data to compare with" empty instead of adding the original value there, too.

Production build 0.69.0 2024