Fix status check not rendering before 5.19 migrations
authorPatrick Figel <pfigel@greenpeace.org>
Mon, 7 Oct 2019 17:05:59 +0000 (19:05 +0200)
committerPatrick Figel <pfigel@greenpeace.org>
Mon, 7 Oct 2019 17:05:59 +0000 (19:05 +0200)
This fixes an issue where the status check page does not render when
migrations to 5.19 are pending because the is_active column hasn't been
added yet.

The rationale for this change is to avoid scenarios where users forget
to run upgrades because there's no status check warning.

CRM/Utils/Check/Component.php

index 0c07a9395334cf6462860964931825574655d7c7..3772b4b3836b38488c87715929e6e91e94510a6f 100644 (file)
@@ -104,11 +104,19 @@ abstract class CRM_Utils_Check_Component {
    * @throws \Civi\API\Exception\UnauthorizedException
    */
   public function isDisabled($method) {
-
-    $checks = $this->getChecksConfig();
-    if (!empty($checks[$method])) {
-      return (bool) empty($checks[$method]['is_active']);
+    try {
+      $checks = $this->getChecksConfig();
+      if (!empty($checks[$method])) {
+        return (bool) empty($checks[$method]['is_active']);
+      }
     }
+    catch (PEAR_Exception $e) {
+      // if we're hitting this, DB migration to 5.19 probably hasn't run yet, so
+      // is_active doesn't exist. Ignore this error so the status check (which
+      // might warn about missing migrations!) still renders.
+      // TODO: remove at some point after 5.19
+    }
+
     return FALSE;
   }