TypeError: Drupal\tamper\Plugin\Tamper\KeywordFilter::match(): Argument#3 ($word_list) must be of type array

Created on 1 May 2023, over 1 year ago
Updated 27 June 2023, over 1 year ago

Problem/Motivation

When using a "Keyword Filter" action, you get this error on the site.

Steps to reproduce

Add a keyword filter action, with lines in the "Words" field. Execute the ECA.

Proposed resolution

In the Tamper base class, when applying tokens to the configuration field, add special handling for lists (arrays) -- the token replacement functions are replacing the array of values from this field with a string "Array", which leads to failure.

📌 Task
Status

Postponed: needs info

Version

1.0

Component

Code

Created by

🇺🇸United States freelock Seattle

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

Comments & Activities

  • Issue created by @freelock
  • 🇩🇪Germany jurgenhaas Gottmadingen

    There is already a comment in the code at \Drupal\eca_tamper\Plugin\Action\Tamper::execute:

        // @todo We may want to call the validate and submit functions for the
        // tamper plugin so that they can update configuration based on final values
        // like e.g. required for the KeywordFilter plugin.
    

    The tamper plugins have some unusual logic which uses the validate function of the configuration form to alter and otherwise prepare configuration of the plugin.

    In the ECA context, we can't call that validation when saving the "configuration form", which in our case is the ECA model, because at that time we don't have the real data yet which will later be processed by ECA and the tamper plugin. To resolve this, we may have to call the validation just prior to execution. Unfortunately, at that point we don't have a form nor a form state object at hand and would have to build some on the fly.

    Wish, there was a better way of doing this, e.g. if the tamper plugins were to provide a helper function that does the config pre-processing which could be called directly and likewise from validation. I may propose that in an issue in the tamper module.

  • 🇩🇪Germany jurgenhaas Gottmadingen
  • Status changed to Postponed: needs info over 1 year ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Waiting for the related issue to be addressed.

  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy kopeboy Milan

    Actually I get the same error even if not using token substitutions in the "Words or phrases to filter on" but just a simple, fixed word string.
    Notice that this instead works on feeds_tamper module (which I guess was the main usecase for which Tamper was created in the first place), so probably we should look there instead of tamper module itself on how to fix this base (much less useful than with tokens) case?

    At least this basic part could be considered a bug that needs work?
    I'm attaching a simple ECA model to reproduce it.

    Note that it will always give this error, with any of the options "Respect word boundaries" or "Exact".

  • 🇮🇹Italy kopeboy Milan

    I leave this little documentation for others that might jump into this error:
    a better alternative for an exact match filter might be to use the "List: Remove item" action (from eca_base module itself) with method "Drop by specified index key" or "Drop by specified value", where you can use token substitutions. That worked perfectly for the example usecase attached.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    Yes, this is not about using tokens, it's about how the upstream tamper plugin handles the config data. So, once the referenced issue is being addressed, it should work here as well.

  • Status changed to Postponed: needs info over 1 year ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Setting back the status as we need to wait for the tamper module to fix the related issue.

Production build 0.71.5 2024