Completed timestamp logic is brittle

Created on 6 January 2024, 6 months ago
Updated 20 January 2024, 5 months ago

Problem/Motivation

The logic in Registration::preSave() executes before hook_ENTITY_TYPE_presave(), which means if you set the state to 'complete' in a presave hook, then no completed timestamp will ever be saved, and RegisterForm::useAdvancedForm will throw an error when it tries to format a NULL datetime.

It's debatable whether the problem here is that it's too easy to end up with no completed timestamp, or that RegisterForm is not defensive enough.

I can see an argument that setting the completed time in Registration::preSave() is not optimal, and it would be better to have a Registration::setState() method and make that responsible for the completed time logic (the setter could be called from ::preSave() as a backup too).

Proposed resolution

Make RegisterForm more defensive.

Remaining tasks

None

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Fixed

Version

3.1

Component

Registration Core

Created by

πŸ‡¬πŸ‡§United Kingdom jonathanshaw Stroud, UK

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024