Estimated Read Time module make webform send emails twice

Created on 19 May 2023, about 1 year ago
Updated 25 September 2023, 9 months ago

Hi, after a long debug I've discovered that the latest Estimated Read Time version has a huge impact on Webform module. I've reproduced the bug on a clean D10 installation with default Webform and Estimated Read Time settings.

Just create a simple webform with an email handler and try to make a submission: the email will be sent twice if Estimated Read Time is enabled.

The bug is on estimated_read_time_entity_insert():

/**
 * Implements hook_entity_insert().
 */
function estimated_read_time_entity_insert(EntityInterface $entity) {
  // Set the read time for new entities.
  if (!$entity instanceof FieldableEntityInterface) {
    return;
  }

  estimated_read_time_set_estimated_read_time($entity);
  $entity->save();
}

More precisely the $entity->save triggers the webform submission (which also is an entity). This should not be done because it can generate errors like this.

As reference please look at the hook_entity_insert documentation:

https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!entity.api...

Let me know what you think about.

Thank you.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇹Italy FiNeX

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

Comments & Activities

Production build 0.69.0 2024