Do not fatally fail on angular pages if an extension is missing
authoreileen <emcnaughton@wikimedia.org>
Fri, 14 Feb 2020 02:07:08 +0000 (15:07 +1300)
committereileen <emcnaughton@wikimedia.org>
Fri, 14 Feb 2020 02:08:23 +0000 (15:08 +1300)
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
CRM/Extension/Mapper.php

index 01c66c249ecd2e3a739ad0a4767a1f6fe8d25757..f55c5687e4163ceeea7d57f11c84fec16dc72cf5 100644 (file)
@@ -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);
 
index 43426192cd50f14b0af1cabc75135cdfb005256d..72c6868a8bbfe305554d231f710abdd3b23861bc 100644 (file)
@@ -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;