Return FALSE instead of throwing Exception if package throws Exception
[civicrm-core.git] / CRM / Extension / System.php
index 6aeaa30baed776e5bfbf0f375e5bb05b30cc2735..a45cbfbadfb7a2b954846a7c69009e85e78709a6 100644 (file)
@@ -51,7 +51,7 @@ class CRM_Extension_System {
   /**
    * The URL of the remote extensions repository.
    *
-   * @var string|FALSE
+   * @var string|false
    */
   private $_repoUrl = NULL;
 
@@ -89,6 +89,8 @@ class CRM_Extension_System {
   }
 
   /**
+   * Class constructor.
+   *
    * @param array $parameters
    *   List of configuration values required by the extension system.
    *   Missing values will be guessed based on $config.
@@ -153,6 +155,12 @@ class CRM_Extension_System {
         }
       }
 
+      if (!defined('CIVICRM_TEST')) {
+        foreach ($containers as $container) {
+          $container->addFilter([__CLASS__, 'isNotTestExtension']);
+        }
+      }
+
       $this->fullContainer = new CRM_Extension_Container_Collection($containers, $this->getCache(), 'full');
     }
     return $this->fullContainer;
@@ -256,7 +264,7 @@ class CRM_Extension_System {
    */
   public function getCache() {
     if ($this->cache === NULL) {
-      $cacheGroup = md5(serialize(['ext', $this->parameters]));
+      $cacheGroup = md5(serialize(['ext', $this->parameters, CRM_Utils_System::version()]));
       // Extension system starts before container. Manage our own cache.
       $this->cache = CRM_Utils_Cache::create([
         'name' => $cacheGroup,
@@ -300,6 +308,10 @@ class CRM_Extension_System {
     return Civi::$statics[__CLASS__]['compatibility'];
   }
 
+  public static function isNotTestExtension(CRM_Extension_Info $info) {
+    return (bool) !preg_match('/^test\./', $info->key);
+  }
+
   /**
    * Take an extension's raw XML info and add information about the
    * extension's status on the local system.
@@ -350,6 +362,9 @@ class CRM_Extension_System {
       default:
         $extensionRow['statusLabel'] = '(' . $extensionRow['status'] . ')';
     }
+    if ($manager->isIncompatible($obj->key)) {
+      $extensionRow['statusLabel'] = ts('Obsolete') . ($extensionRow['statusLabel'] ? (' - ' . $extensionRow['statusLabel']) : '');
+    }
     return $extensionRow;
   }