I am trying to save a webform submission inside the postSave in a CustomWebformHandler
class.
class CustomWebformHandler extends WebformHandlerBase {
[..]
public function postSave(WebformSubmissionInterface $webform_submission, $update = TRUE) {
$data = $webform_submission->getData();
$data['ssa_attachment'] = $doc_id; //doc_id is retrieved with a query
$webform_submission->setData($data);
$webform_submission->set('in_draft', TRUE);
$webform_submission->save();
}
}
I get the following exception.
Uncaught PHP Exception Drupal\Core\Entity\EntityStorageException: "Entity validation was skipped."
I tried to validate before saving and I get this exception.
Uncaught PHP Exception Drupal\Core\Entity\EntityStorageException: "SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction: SELECT w.next_serial AS next_serial\nFROM\n{webform} w\nWHERE webform_id = :db_condition_placeholder_0 FOR UPDATE;
How can I trigger the validation before saving?
$webform_submission->save()
, which leads to a stack overflow if no other random error occurs first. – 4k4 Nov 14 '19 at 13:41