Fatal error due to malformed $params in CRM_Grant_BAO_GrantApplicationPage::sendMail()
When submitting a grant application that includes custom data, the process of generating the confirmation email fails with an error like the below:
preg_match(): Argument #2 ($subject) must be of type string, array given
in /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/BAO/CustomField.php at line 765
#0 /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/BAO/CustomField.php(765): preg_match()
#1 /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Contact/BAO/Query.php(655): CRM_Core_BAO_CustomField::getKeyID()
#2 /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Contact/BAO/Query.php(559): CRM_Contact_BAO_Query->buildParamsLookup()
#3 /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Contact/BAO/Query.php(524): CRM_Contact_BAO_Query->initialize()
#4 /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/BAO/UFGroup.php(982): CRM_Contact_BAO_Query->__construct()
#5 /home/cses_org_uk/public_html/media/civicrm/ext/biz.jmaconsulting.grantapplications/CRM/Grant/BAO/GrantApplicationPage.php(602): CRM_Core_BAO_UFGroup::getValues()
#6 /home/cses_org_uk/public_html/media/civicrm/ext/biz.jmaconsulting.grantapplications/CRM/Grant/BAO/GrantApplicationPage.php(406): CRM_Grant_BAO_GrantApplicationPage::buildCustomProfile()
#7 /home/cses_org_uk/public_html/media/civicrm/ext/biz.jmaconsulting.grantapplications/CRM/Grant/BAO/Grant/Utils.php(86): CRM_Grant_BAO_GrantApplicationPage::sendMail()
#8 /home/cses_org_uk/public_html/media/civicrm/ext/biz.jmaconsulting.grantapplications/CRM/Grant/Form/Grant/Confirm.php(545): CRM_Grant_BAO_Grant_Utils::processConfirm()
#9 /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/Form.php(617): CRM_Grant_Form_Grant_Confirm->postProcess()
#10 /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/StateMachine.php(144): CRM_Core_Form->mainProcess()
#11 /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/QuickForm/Action/Next.php(43): CRM_Core_StateMachine->perform()
#12 /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Next->perform()
#13 /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle()
#14 /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/Controller.php(355): HTML_QuickForm_Page->handle()
#15 /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(322): CRM_Core_Controller->run()
#16 /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(69): CRM_Core_Invoke::runItem()
#17 /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke()
#18 /home/cses_org_uk/public_html/components/com_civicrm/civicrm.php(84): CRM_Core_Invoke::invoke()
#19 /home/cses_org_uk/public_html/components/com_civicrm/civicrm.php(11): civicrm_invoke()
#20 /home/cses_org_uk/public_html/libraries/src/Component/ComponentHelper.php(402): require_once('...')
#21 /home/cses_org_uk/public_html/libraries/src/Component/ComponentHelper.php(377): Joomla\CMS\Component\ComponentHelper::executeComponent()
#22 /home/cses_org_uk/public_html/libraries/src/Application/SiteApplication.php(194): Joomla\CMS\Component\ComponentHelper::renderComponent()
#23 /home/cses_org_uk/public_html/libraries/src/Application/SiteApplication.php(233): Joomla\CMS\Application\SiteApplication->dispatch()
#24 /home/cses_org_uk/public_html/libraries/src/Application/CMSApplication.php(225): Joomla\CMS\Application\SiteApplication->doExecute()
#25 /home/cses_org_uk/public_html/index.php(49): Joomla\CMS\Application\CMSApplication->execute()
#26 {main}
This is because the $params
variable built up in CRM_Grant_BAO_GrantApplicationPage::sendMail()
has too many levels of nesting for the custom_pre_id
and custom_post_id
elements (where used):
$params = Array
(
[0] => Array
(
[0] => contact_id
[1] => =
[2] => 98
[3] => 0
[4] => 0
)
[custom_post_id] => Array
(
[0] => Array
(
[0] => grant_id
[1] => =
[2] => 92
[3] => 0
[4] => 0
)
)
)
Should be:
$params = Array
(
[0] => Array
(
[0] => contact_id
[1] => =
[2] => 98
[3] => 0
[4] => 0
)
[custom_post_id] => Array
(
[0] => grant_id
[1] => =
[2] => 92
[3] => 0
[4] => 0
)
)
So that just the "grant_id" gets passed to CRM_Core_BAO_CustomField::getKeyID()
, and not the whole sub-array of conditions.