Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Trivial
-
Resolution: Won't Fix
-
Affects Version/s: 2.2.7
-
Fix Version/s: 4.3.0
-
Component/s: Core CiviCRM
-
Labels:None
Description
Problem occurred when registering a contact for an event from the contact's Events tab -> New event reg. Numerous custom fields have been set up for event participants. On submitting the registration with email confirmation checked & just the (two) mandatory custom fields completed, got a white screen. Nothing in CiviCRM.log . Apache error log had:
PHP Fatal error: Call to a member function fetch() on a non-object in /var/www/blah/sites/all/modules/civicrm/CRM/Core/BAO/CustomGroup.php on line 1551, referer: http://www.mysite.org/civicrm/contact/view/participant?reset=1&action=add&cid=8901&context=participant
(this line number refers to the 2.2.5 version; corresponding line is 1552 in 2.2.7:
while ( $coDAO->fetch( ) ) {
- in formatCustomValues)
I tracked this down using debug statements in CustomGroup.php, checking for !is_object($coDAO). When this occurred:
$value was empty
$htmlType was Select
$dataType was String
$option_group_id was empty
$field related to a drop-down that appears fine.
There seems to be a logic error in function formatCustomValues:
switch( $dataType )
where $dataType is Int or String falls through to StateProvince / Country unless $htmlType is Text or TextArea. The error occurs within the case Country, which should not be reached here.
There are similar problems where $dataType is Float or Money.
I fixed my case by moving the break under Int/String from inside
if ( in_array($htmlType, array('Text', 'TextArea')) )
to outside (from line 1488 to 1489). I believe similar changes are needed for the Float and Money cases.
Rather than submit a patch I thought it might be best for someone to do a code review of this function, in case further issues lurk.