PseudoConstant - Prevent fatal when entity not available
authorcolemanw <coleman@civicrm.org>
Thu, 7 Sep 2023 17:38:12 +0000 (13:38 -0400)
committercolemanw <coleman@civicrm.org>
Thu, 7 Sep 2023 18:37:40 +0000 (14:37 -0400)
This can happen e.g when Views tries to lookup an option value for a disabled extension.
See https://github.com/civicrm/civicrm-drupal/pull/656#issuecomment-1094362139

CRM/Core/PseudoConstant.php

index 17dd76dbe1fb81d4d794bf29ad579005a10812b3..4a86234f1f837fc7b9964b93c44428b2c00103cf 100644 (file)
@@ -209,8 +209,10 @@ class CRM_Core_PseudoConstant {
     }
 
     // Core field: load schema
-    $dao = new $daoName();
-    $fieldSpec = $dao->getFieldSpec($fieldName);
+    if (class_exists($daoName)) {
+      $dao = new $daoName();
+      $fieldSpec = $dao->getFieldSpec($fieldName);
+    }
 
     // Return false if field doesn't exist.
     if (empty($fieldSpec)) {