Problem/Motivation

After update to the latest supported version (2.0.9) these errors are shown when update hooks are run:

[error] Found config field fallback in eca_tamper_condition:strtotime with non-supported value.
[error] Found config field fallback in eca_tamper:strtotime with non-supported value.

(I think unrelated, but mixed in was "[error] ECA ran into error from third party in the context of "Collecting all available actions":
> \Drupal\entity\Plugin\Action\DeleteAction has been deprecated in favor of \Drupal\Core\Action\Plugin\Action\DeleteAction. Use that instead.
> Line 7 of /var/www/html/web/modules/contrib/entity/src/Plugin/Action/DeleteAction.php ")

Steps to reproduce

Run eca_update_8011

Proposed resolution

Document, in this issue anyway, what should be fixed.

Would've been nice to have which models had the problem.

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork tamper-3560959

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mlncn created an issue. See original summary.

mlncn’s picture

Logs do not provide more information and neither "strtotime" nor "fallback" appear at all in any ECA configuration so really not sure how this can be fixed by the sitebuilder?

jurgenhaas’s picture

Title: What is the correct fix to update error field fallback strtotime with non-supported value? » Plugin strToTime is missing defaultConfiguration()
Project: ECA Tamper Integration » Tamper
Version: 2.0.x-dev » 8.x-1.x-dev
Category: Support request » Task

The tamper plugins are coming from the tamper module, moving the issue over there.

The reason for the error message is that the strToDate plugin has 2 config properties but the defaultConfiguration() method is missing. Therefore, the fallback for both properties is an empty string, which is not a valid default value for a checkbox. If the default values will be added (similar to e.g. \Drupal\tamper\Plugin\Tamper\TruncateText::defaultConfiguration), then the error messages will be gone.

The other error message is a deprecation message from Drupal core which has to be ignored, we can't do anything about that. EDIT: it's not from core, it comes from the entity module, and there is this issue available with a proposed fix: #3532309: Fix Deprecation notice from DeleteAction class causes errors in ECA module

None of the above error messages should prevent the update hook from doing its work, though.

megachriz’s picture

Hm, for this particular plugin, the defaults should be NULL. I think that's why defaultConfiguration() is not defined. The method getSetting() would return NULL if the setting key is not defined.

Is a checkbox field not allowed to have NULL as default? Then it should probably become FALSE if $this->getSetting(static::SETTING_FALLBACK) returns NULL.

Current code for the checkbox field:

$form[static::SETTING_FALLBACK] = [
  '#type' => 'checkbox',
  '#title' => t('Fallback to strtotime() if the date could not be parsed with the provided date format.'),
  '#default_value' => $this->getSetting(static::SETTING_FALLBACK),
  '#states' => [
    'visible' => [
      'input[name="plugin_configuration[date_format]"]' => ['filled' => TRUE],
    ],
  ],
];

(note: I see it is calling t() instead of $this->t().)

But I'm willing to define defaultConfiguration() just with both setting keys set to NULL. Would that help?

jurgenhaas’s picture

I think that NULL is not a valid default for checkboxes, it should indeed be FALSE. And the default for the date format should be an empty string, I'd say.

Those 2 values would also be the settings that you get from \Drupal\tamper\Plugin\Tamper\StrToTime::submitConfigurationForm when the form gets submitted, even if the default values had been NULL.

megachriz’s picture

Status: Active » Needs review

Do the changes in the MR help to resolve the issue?

jurgenhaas’s picture

Status: Needs review » Reviewed & tested by the community

LGTM

darkodev’s picture

Thanks, the MR fixes the "Found config field fallback" messages for me, too.

megachriz’s picture

Status: Reviewed & tested by the community » Fixed

Merging the code is scheduled to be merged. Thanks all for testing!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • megachriz committed 6d52e1d4 on 8.x-1.x
    fix: #3560959 Added missing default configuration for plugin "strToTime...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.