Fatal error on membership batch data entry with sending receipt
Overview
When trying to submit membership in batch having Send Receipt checkbox enabled, civi will throw a fatal error due to a bug in code.
Reproduction steps
From Membership -> Batch Data Entry -> Select Type: Membership -> Save -> Check "Send Receipt" -> Validate & Process the Batch -> Ignore Mismatch & Process the Batch?
Current behaviour
On submit will throw this fatal error:
Fatal error: Uncaught TypeError: Argument 1 passed to CRM_Utils_Date::formatDateOnlyLong() must be of the type string, null given, called in wp-civi560/web/wp-content/plugins/civicrm/civicrm/CRM/Batch/Form/Entry.php on line 949 and defined in wp-civi560/web/wp-content/plugins/civicrm/civicrm/CRM/Utils/Date.php on line 472
TypeError: Argument 1 passed to CRM_Utils_Date::formatDateOnlyLong() must be of the type string, null given, called in wp-civi560/web/wp-content/plugins/civicrm/civicrm/CRM/Batch/Form/Entry.php on line 949 in wp-civi560/web/wp-content/plugins/civicrm/civicrm/CRM/Utils/Date.php on line 472
Expected behaviour
It should process the memberships without throwing error.
Environment information
Tested on a clean civibuild instance with latest CiviCRM and WP.
- Browser: Arc 0.98.2
- CiviCRM: 5.60
- PHP: 7.4.27
- CMS: WordPress 6.2
- Database: MySQL 5.7.36
- Web Server: Apache 2.4.53
Comments
The issue seems to be this line, it attempts to fetch before find, which lead to empty $membership
object. Replacing it with $membership->find(TRUE)
fixes the problem.