Event Price set returns an error if expiry date is removed.
This is slightly a case of user error but would be good to handle it in code.
To replicate, make sure the time input format is set to 24 hrs https://dmaster.demo.civicrm.org/civicrm/admin/setting/date?reset=1
-
Create a price set for Event from https://dmaster.demo.civicrm.org/civicrm/admin/price?reset=1&action=add
-
Add a price field and set an expiry date in future.
-
Use this priceset on an event. (No issues till now).
-
Edit the pricefield created at step 2 and remove the date field as shown in the screenshot, i.e, do not use the clear icon
x
.
- Since the time is still present, the value is stored in the table as
0000-00-00 00:00:00
.
With this value in the table, civi still considers this price field as expired and you see the below error on event registration page -
2 Possible Fixes:
-
store NULL for the expiry date column if there is no date selected by the user OR
-
Let user store this value in the database, but do not consider it as expired. So an extra OR clause at https://github.com/civicrm/civicrm-core/blob/master/CRM/Price/BAO/PriceSet.php#L464 to look like -
AND ( expire_on IS NULL OR expire_on = '0000-00-00 00:00:00' OR expire_on >= {$currentTime} )
I think 0000-00-00 00:00:00
is a dummy date value and it would be better to store this as NULL. But i see this problem is with all the date fields present in civicrm. All seems to store the value as 0000-00-00 00:00:00 if the field is not cleared using the x
icon. Eg receipt date
in contribution, etc.