From 78280a63a3f9bde8e32f6818d3d61cbe43d4c0ff Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 14 Feb 2020 15:07:08 +1300 Subject: [PATCH] Do not fatally fail on angular pages if an extension is missing If an extension is missing trying to create a new mailing will totally fail - on QF pages we just get a not-very-clear message --- CRM/Extension/Container/Interface.php | 2 ++ CRM/Extension/Mapper.php | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CRM/Extension/Container/Interface.php b/CRM/Extension/Container/Interface.php index 01c66c249e..f55c5687e4 100644 --- a/CRM/Extension/Container/Interface.php +++ b/CRM/Extension/Container/Interface.php @@ -43,6 +43,8 @@ interface CRM_Extension_Container_Interface { * * @param string $key * Fully-qualified extension name. + * + * @throws \CRM_Extension_Exception_MissingException */ public function getResUrl($key); diff --git a/CRM/Extension/Mapper.php b/CRM/Extension/Mapper.php index 43426192cd..72c6868a8b 100644 --- a/CRM/Extension/Mapper.php +++ b/CRM/Extension/Mapper.php @@ -236,9 +236,11 @@ class CRM_Extension_Mapper { * * @return string * url for resources in this extension + * + * @throws \CRM_Extension_Exception_MissingException */ public function keyToUrl($key) { - if ($key == 'civicrm') { + if ($key === 'civicrm') { // CRM-12130 Workaround: If the domain's config_backend is NULL at the start of the request, // then the Mapper is wrongly constructed with an empty value for $this->civicrmUrl. if (empty($this->civicrmUrl)) { @@ -339,6 +341,8 @@ class CRM_Extension_Mapper { * * @return array * (string $extKey => string $baseUrl) + * + * @throws \CRM_Extension_Exception_MissingException */ public function getActiveModuleUrls() { // TODO optimization/caching @@ -347,7 +351,12 @@ class CRM_Extension_Mapper { foreach ($this->getModules() as $module) { /** @var $module CRM_Core_Module */ if ($module->is_active) { - $urls[$module->name] = $this->keyToUrl($module->name); + try { + $urls[$module->name] = $this->keyToUrl($module->name); + } + catch (CRM_Extension_Exception_MissingException $e) { + CRM_Core_Session::setStatus(ts('An enabled extension is missing from the extensions directory') . ':' . $module->name); + } } } return $urls; -- 2.25.1