Grant application page does not load (breaks between CiviCRM 5.66 and 5.72)
Since upgrading to CiviCRM 5.66 to 5.72, the grant application pages have stopped loading on the front-end website. A blank page displays instead.
Looking into the error_log, I see messages like the following:
[Fri Apr 12 13:21:51.316170 2024] [fcgid:warn] [pid 53486] [client 84.70.161.232:56586] mod_fcgid: stderr: PHP Warning: Smarty error: unable to read resource: "CRM/Grant/Form/Grant/Main.tpl" in /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/packages/Smarty/Smarty.class.php on line 1193, referer: https://cses.org.uk/education/bursary
The problem seems to be in CRM_Grant_Form_GrantBase::getTemplateFileName()
, which defers the call to the parent class (CRM_Core_Form
) if the default path does not exist.
In CRM_Core_Form::getTemplateFileName()
, a call is made to CRM_Extension_Mapper::isExtensionClass()
to determine whether the call has been made from an extension class and (presumably) therefore whether a path should be returned relative to the extension folder. Unfortunately, this check fails because the class name starts with CRM_
.
I am not sure what the long-term fix is here, but I have found that wrapping the call to parent::getTemplateFileName()
in E::path()
seems to fix it:
/**
* Use the form name to create the tpl file name.
*
* @return string
*/
public function getTemplateFileName() {
$fileName = $this->checkTemplateFileExists();
return $fileName ? $fileName : E::path('templates/'.parent::getTemplateFileName());
// Add path wrapper: ^^^^^^^^^^^^^^^^^^^^^ ^
}