Merge pull request #15321 from yashodha/dev_1065
[civicrm-core.git] / CRM / Extension / Mapper.php
index 926d7086c3f9448d3e5968089215420c79096cc6..fd828e4fe771e54a8a85776317fdf969e521ba48 100644 (file)
@@ -63,7 +63,7 @@ class CRM_Extension_Mapper {
   /**
    * @var array (key => CRM_Extension_Info)
    */
-  protected $infos = array();
+  protected $infos = [];
 
   /**
    * @var array
@@ -275,9 +275,9 @@ class CRM_Extension_Mapper {
    *   array(array('prefix' => $, 'file' => $))
    */
   public function getActiveModuleFiles($fresh = FALSE) {
-    $config = CRM_Core_Config::singleton();
-    if ($config->isUpgradeMode() || !defined('CIVICRM_DSN')) {
-      return array(); // hmm, ok
+    if (!defined('CIVICRM_DSN')) {
+      // hmm, ok
+      return [];
     }
 
     $moduleExtensions = NULL;
@@ -286,8 +286,10 @@ class CRM_Extension_Mapper {
     }
 
     if (!is_array($moduleExtensions)) {
+      $compat = CRM_Extension_System::getCompatibilityInfo();
+
       // Check canonical module list
-      $moduleExtensions = array();
+      $moduleExtensions = [];
       $sql = '
         SELECT full_name, file
         FROM civicrm_extension
@@ -296,21 +298,24 @@ class CRM_Extension_Mapper {
       ';
       $dao = CRM_Core_DAO::executeQuery($sql);
       while ($dao->fetch()) {
+        if (!empty($compat[$dao->full_name]['force-uninstall'])) {
+          continue;
+        }
         try {
-          $moduleExtensions[] = array(
+          $moduleExtensions[] = [
             'prefix' => $dao->file,
             'filePath' => $this->keyToPath($dao->full_name),
-          );
+          ];
         }
         catch (CRM_Extension_Exception $e) {
           // Putting a stub here provides more consistency
           // in how getActiveModuleFiles when racing between
           // dirty file-removals and cache-clears.
           CRM_Core_Session::setStatus($e->getMessage(), '', 'error');
-          $moduleExtensions[] = array(
+          $moduleExtensions[] = [
             'prefix' => $dao->file,
             'filePath' => NULL,
-          );
+          ];
         }
       }
 
@@ -329,7 +334,7 @@ class CRM_Extension_Mapper {
    */
   public function getActiveModuleUrls() {
     // TODO optimization/caching
-    $urls = array();
+    $urls = [];
     $urls['civicrm'] = $this->keyToUrl('civicrm');
     foreach ($this->getModules() as $module) {
       /** @var $module CRM_Core_Module */
@@ -352,7 +357,7 @@ class CRM_Extension_Mapper {
    *   Ex: array("org.foo.bar").
    */
   public function getKeysByPath($pattern) {
-    $keys = array();
+    $keys = [];
 
     if (CRM_Utils_String::endsWith($pattern, '*')) {
       $prefix = rtrim($pattern, '*');
@@ -410,7 +415,7 @@ class CRM_Extension_Mapper {
    *   CRM_Core_Module
    */
   public function getModules() {
-    $result = array();
+    $result = [];
     $dao = new CRM_Core_DAO_Extension();
     $dao->type = 'module';
     $dao->find();
@@ -458,7 +463,7 @@ class CRM_Extension_Mapper {
   }
 
   public function refresh() {
-    $this->infos = array();
+    $this->infos = [];
     $this->moduleExtensions = NULL;
     if ($this->cache) {
       $this->cache->delete($this->cacheKey . '_moduleFiles');