From 40ad8f6a893f953f8a1c6dba823c98b16d586245 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 5 Nov 2021 14:59:47 +1300 Subject: [PATCH] Fix isForm to be always assigned, remove checks Note I'm not seeing any regressions on this locally with enotice turned on - but the worst case, if tests pass, is we get some enotices back in a scenario where we are only impacting bleeding edge devs --- CRM/Core/Page.php | 11 +++++++++++ templates/CRM/common/CMSPrint.tpl | 2 +- templates/CRM/common/joomla.tpl | 2 +- templates/CRM/common/print.tpl | 2 +- templates/CRM/common/printBody.tpl | 2 +- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CRM/Core/Page.php b/CRM/Core/Page.php index f83b170f93..08b614e651 100644 --- a/CRM/Core/Page.php +++ b/CRM/Core/Page.php @@ -97,6 +97,16 @@ class CRM_Core_Page { */ public $useLivePageJS; + /** + * Variables smarty expects to have set. + * + * We ensure these are assigned (value = NULL) when Smarty is instantiated in + * order to avoid e-notices / having to use empty or isset in the template layer. + * + * @var string[] + */ + public $expectedSmartyVariables = ['breadcrumb', 'pageTitle', 'isForm', 'hookContent']; + /** * Class constructor. * @@ -116,6 +126,7 @@ class CRM_Core_Page { if (!isset(self::$_template)) { self::$_template = CRM_Core_Smarty::singleton(); self::$_session = CRM_Core_Session::singleton(); + self::$_template->ensureVariablesAreAssigned($this->expectedSmartyVariables); } // FIXME - why are we messing with 'snippet'? Why not just pass it directly into $this->_print? diff --git a/templates/CRM/common/CMSPrint.tpl b/templates/CRM/common/CMSPrint.tpl index 919869faf3..482191ae23 100644 --- a/templates/CRM/common/CMSPrint.tpl +++ b/templates/CRM/common/CMSPrint.tpl @@ -40,7 +40,7 @@
{include file="CRM/common/status.tpl"} {crmRegion name='page-body'} - {if isset($isForm) and $isForm and isset($formTpl)} + {if $isForm and $formTpl} {include file="CRM/Form/$formTpl.tpl"} {else} {include file=$tplFile} diff --git a/templates/CRM/common/joomla.tpl b/templates/CRM/common/joomla.tpl index ec33072425..32e5859ecc 100644 --- a/templates/CRM/common/joomla.tpl +++ b/templates/CRM/common/joomla.tpl @@ -53,7 +53,7 @@
{include file="CRM/common/status.tpl"} {crmRegion name='page-body'} - {if isset($isForm) and $isForm and isset($formTpl)} + {if $isForm and $formTpl} {include file="CRM/Form/$formTpl.tpl"} {else} {include file=$tplFile} diff --git a/templates/CRM/common/print.tpl b/templates/CRM/common/print.tpl index e144095c46..9ee4858ec6 100644 --- a/templates/CRM/common/print.tpl +++ b/templates/CRM/common/print.tpl @@ -29,7 +29,7 @@ {include file="CRM/common/status.tpl"} {crmRegion name='page-body' allowCmsOverride=0} - {if $isForm and isset($formTpl)} + {if $isForm and $formTpl} {include file="CRM/Form/$formTpl.tpl"} {else} {include file=$tplFile} diff --git a/templates/CRM/common/printBody.tpl b/templates/CRM/common/printBody.tpl index 81ac3afef8..d1c0913431 100644 --- a/templates/CRM/common/printBody.tpl +++ b/templates/CRM/common/printBody.tpl @@ -9,7 +9,7 @@ *} {* printBody.tpl: wrapper for Print views without HTML surrounds. *} -{if $isForm and isset($formTpl)} +{if $isForm and $formTpl} {include file="CRM/Form/$formTpl.tpl"} {else} {include file=$tplFile} -- 2.25.1