From 8d2c99cfe807f27dad36cebbf4f5165eef32efe2 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 17 Aug 2020 22:05:02 -0700 Subject: [PATCH] CRM_Core_Resources::addCoreResources - Option `$region` is not meaningfully used If you grep universe for `addCoreResources` and `addCoreStyles`, all matches fall into these buckets: 1. They use the implicit default region. 2. They explicitly use the `html-header` region. 3. (Singular case) addCoreResources($region) delegates to addCoreStyles($region); but given 1+2, this must still be `html-header`. --- CRM/Core/Resources.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index 4265fee1cf..3ac2b72e88 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -564,6 +564,13 @@ class CRM_Core_Resources { * @return CRM_Core_Resources */ public function addCoreResources($region = 'html-header') { + if ($region !== 'html-header') { + // The signature of this method allowed different regions. However, this + // doesn't appear to be used - based on grepping `universe` generally + // and `civicrm-{core,backdrop,drupal,packages,wordpress,joomla}` specifically, + // it appears that all callers use 'html-header' (either implicitly or explicitly). + throw new \CRM_Core_Exception("Error: addCoreResources only supports html-header"); + } if (!isset($this->addedCoreResources[$region]) && !self::isAjaxMode()) { $this->addedCoreResources[$region] = TRUE; $config = CRM_Core_Config::singleton(); @@ -616,6 +623,13 @@ class CRM_Core_Resources { * @return CRM_Core_Resources */ public function addCoreStyles($region = 'html-header') { + if ($region !== 'html-header') { + // The signature of this method allowed different regions. However, this + // doesn't appear to be used - based on grepping `universe` generally + // and `civicrm-{core,backdrop,drupal,packages,wordpress,joomla}` specifically, + // it appears that all callers use 'html-header' (either implicitly or explicitly). + throw new \CRM_Core_Exception("Error: addCoreResources only supports html-header"); + } if (!isset($this->addedCoreStyles[$region])) { $this->addedCoreStyles[$region] = TRUE; -- 2.25.1