Webform handler postSave() method is triggered before completing the database transaction

Created on 24 February 2023, over 1 year ago
Updated 20 April 2024, 7 months ago

Problem/Motivation

We have a custom Webform Handler in which we used the postSave method. We implemented something incorrectly in this method containing a die() at some point. While this is quite dirty and incorrect, we still did this confidently because the postSave() method name suggests that the submission already has been saved to the database safely.

This has worked correctly for many years, however as off our latest module updates this suddenly broke. It turned out that during the execution of the postSave method, the submission was available, but the database transaction wasn't yet committed. So at the point of our die() statement, the submission was never actually being saved to the database, causing a lot of loss of data.

While this was due to dirty code on our side (which is now fixed), this may still occur if for example a fatal PHP error occurs during the execution of a webform handler.

Steps to reproduce

- Implement a webform handler in a webform
- put a die() statement in the postSave() method of the webform handler
- Submit the webform
- See if the submission has (not) been saved to the database

Proposed resolution

Make sure the database transaction has been committed to the database, before executing the postSave handlers.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

6.1

Component

Code

Created by

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024