CiviGrant Add safeguard to prevent managed errors during upgrade
authorColeman Watts <coleman@civicrm.org>
Tue, 9 Aug 2022 02:28:22 +0000 (22:28 -0400)
committerColeman Watts <coleman@civicrm.org>
Tue, 9 Aug 2022 02:28:22 +0000 (22:28 -0400)
ext/civigrant/managed/OptionGroup_recent_items_providers_OptionValue_Grant.mgd.php

index 2a7c9dd8a1314963bf2a8a1050f584be74d3959c..d0359dd2f4ae36444d21c2681a8967d0c20cc7fe 100644 (file)
@@ -1,6 +1,15 @@
 <?php
 use CRM_Grant_ExtensionUtil as E;
 
+// Prevent errors during upgrades from < 5.53 that don't yet have the option group
+$optionGroup = \Civi\Api4\OptionGroup::get(FALSE)
+  ->addWhere('name', '=', 'recent_items_providers')
+  ->selectRowCount()
+  ->execute();
+if (!$optionGroup->count()) {
+  return [];
+}
+
 return [
   [
     'name' => 'OptionGroup_recent_items_providers_OptionValue_Grant',