From 84b707c27d0e4f57cccccc0e21aef2f01723f684 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 27 Sep 2022 15:52:16 -0400 Subject: [PATCH] RecentItems - Fix inconsistent option values between upgrader & installer Values for new option group were accidentally created with numeric values in the 5.53.alpha1 upgrade, and in the installer their names did not match the names created in the upgrader. --- .../Incremental/php/FiveFiftyThree.php | 31 ++++++++++--------- .../Incremental/sql/5.54.alpha1.mysql.tpl | 12 +++++++ ..._items_providers_OptionValue_Grant.mgd.php | 14 ++------- xml/templates/civicrm_data.tpl | 24 +++++++------- 4 files changed, 43 insertions(+), 38 deletions(-) diff --git a/CRM/Upgrade/Incremental/php/FiveFiftyThree.php b/CRM/Upgrade/Incremental/php/FiveFiftyThree.php index c647da3cd2..0f4513d393 100644 --- a/CRM/Upgrade/Incremental/php/FiveFiftyThree.php +++ b/CRM/Upgrade/Incremental/php/FiveFiftyThree.php @@ -122,23 +122,26 @@ class CRM_Upgrade_Incremental_php_FiveFiftyThree extends CRM_Upgrade_Incremental 'is_reserved' => 0, ]); $values = [ - 'Contact' => ['label' => ts('Contacts')], - 'Relationship' => ['label' => ts('Relationships')], - 'Activity' => ['label' => ts('Activities')], - 'Note' => ['label' => ts('Notes')], - 'Group' => ['label' => ts('Groups')], - 'Case' => ['label' => ts('Cases')], - 'Contribution' => ['label' => ts('Contributions')], - 'Participant' => ['label' => ts('Participants')], - 'Membership' => ['label' => ts('Memberships')], - 'Pledge' => ['label' => ts('Pledges')], - 'Event' => ['label' => ts('Events')], - 'Campaign' => ['label' => ts('Campaigns')], + 'Contact' => ts('Contacts'), + 'Relationship' => ts('Relationships'), + 'Activity' => ts('Activities'), + 'Note' => ts('Notes'), + 'Group' => ts('Groups'), + 'Case' => ts('Cases'), + 'Contribution' => ts('Contributions'), + 'Participant' => ts('Participants'), + 'Membership' => ts('Memberships'), + 'Pledge' => ts('Pledges'), + 'Event' => ts('Events'), + 'Campaign' => ts('Campaigns'), ]; - foreach ($values as $name => $value) { - CRM_Core_BAO_OptionValue::ensureOptionValueExists($value + [ + foreach ($values as $name => $label) { + CRM_Core_BAO_OptionValue::ensureOptionValueExists([ + 'label' => $label, 'name' => $name, + 'value' => $name, 'option_group_id' => 'recent_items_providers', + 'is_reserved' => TRUE, ]); } return TRUE; diff --git a/CRM/Upgrade/Incremental/sql/5.54.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/5.54.alpha1.mysql.tpl index 03d9bcfc39..95af8e28a0 100644 --- a/CRM/Upgrade/Incremental/sql/5.54.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/5.54.alpha1.mysql.tpl @@ -1,2 +1,14 @@ {* file to handle db changes in 5.54.alpha1 during upgrade *} ALTER TABLE `civicrm_mailing_bounce_type` CHANGE `name` `name` VARCHAR(255) NOT NULL COMMENT 'Type of bounce', CHANGE `description` `description` VARCHAR(2048) NULL DEFAULT NULL COMMENT 'A description of this bounce type'; + +SELECT @og_recent_items_providers := max(id) from civicrm_option_group where name = 'recent_items_providers'; + +{* Ensure all recent_items_providers option values are reserved *} +UPDATE `civicrm_option_value` +SET `is_reserved` = 1 +WHERE `option_group_id` = @og_recent_items_providers; + +{* Fix option values accidentally created with numeric values in the 5.53.alpha1 upgrade *} +UPDATE `civicrm_option_value` +SET `value` = `name` +WHERE `option_group_id` = @og_recent_items_providers AND `value` REGEXP '^[0-9]+$'; diff --git a/ext/civigrant/managed/OptionGroup_recent_items_providers_OptionValue_Grant.mgd.php b/ext/civigrant/managed/OptionGroup_recent_items_providers_OptionValue_Grant.mgd.php index d0359dd2f4..2c0d94417d 100644 --- a/ext/civigrant/managed/OptionGroup_recent_items_providers_OptionValue_Grant.mgd.php +++ b/ext/civigrant/managed/OptionGroup_recent_items_providers_OptionValue_Grant.mgd.php @@ -22,19 +22,9 @@ return [ 'option_group_id.name' => 'recent_items_providers', 'label' => E::ts('Grants'), 'value' => 'Grant', - 'name' => 'Grants', - 'grouping' => NULL, - 'filter' => 0, - 'is_default' => FALSE, - 'description' => NULL, - 'is_optgroup' => FALSE, - 'is_reserved' => FALSE, + 'name' => 'Grant', + 'is_reserved' => TRUE, 'is_active' => TRUE, - 'icon' => NULL, - 'color' => NULL, - 'component_id' => NULL, - 'domain_id' => NULL, - 'visibility_id' => NULL, ], ], ], diff --git a/xml/templates/civicrm_data.tpl b/xml/templates/civicrm_data.tpl index 51e01c1745..32b1cc69af 100644 --- a/xml/templates/civicrm_data.tpl +++ b/xml/templates/civicrm_data.tpl @@ -1796,15 +1796,15 @@ SELECT @option_group_id_recent := max(id) from civicrm_option_group where name = INSERT INTO civicrm_option_value (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, {localize field='description'}description{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`) VALUES - (@option_group_id_recent, {localize}'{ts escape="sql"}Contacts{/ts}'{/localize}, 'Contact', 'Contacts', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Relationships{/ts}'{/localize}, 'Relationship', 'Relationships', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Activities{/ts}'{/localize}, 'Activity', 'Activities', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Notes{/ts}'{/localize}, 'Note', 'Notes', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Groups{/ts}'{/localize}, 'Group', 'Groups', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Cases{/ts}'{/localize}, 'Case', 'Cases', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Contributions{/ts}'{/localize}, 'Contribution', 'Contributions', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Participants{/ts}'{/localize}, 'Participant', 'Participants', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Memberships{/ts}'{/localize}, 'Membership', 'Memberships', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Pledges{/ts}'{/localize}, 'Pledge', 'Pledges', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Events{/ts}'{/localize}, 'Event', 'Events', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL), - (@option_group_id_recent, {localize}'{ts escape="sql"}Campaigns{/ts}'{/localize}, 'Campaign', 'Campaigns', NULL, NULL, 0, 1, '', 0, 0, 1, NULL, NULL); + (@option_group_id_recent, {localize}'{ts escape="sql"}Contacts{/ts}'{/localize}, 'Contact', 'Contact', NULL, NULL, 0, 1, '', 0, 1, 1, NULL, NULL), + (@option_group_id_recent, {localize}'{ts escape="sql"}Relationships{/ts}'{/localize}, 'Relationship', 'Relationship', NULL, NULL, 0, 1, '', 0, 1, 1, NULL, NULL), + (@option_group_id_recent, {localize}'{ts escape="sql"}Activities{/ts}'{/localize}, 'Activity', 'Activity', NULL, NULL, 0, 1, '', 0, 1, 1, NULL, NULL), + (@option_group_id_recent, {localize}'{ts escape="sql"}Notes{/ts}'{/localize}, 'Note', 'Note', NULL, NULL, 0, 1, '', 0, 1, 1, NULL, NULL), + (@option_group_id_recent, {localize}'{ts escape="sql"}Groups{/ts}'{/localize}, 'Group', 'Group', NULL, NULL, 0, 1, '', 0, 1, 1, NULL, NULL), + (@option_group_id_recent, {localize}'{ts escape="sql"}Cases{/ts}'{/localize}, 'Case', 'Case', NULL, NULL, 0, 1, '', 0, 1, 1, NULL, NULL), + (@option_group_id_recent, {localize}'{ts escape="sql"}Contributions{/ts}'{/localize}, 'Contribution', 'Contribution', NULL, NULL, 0, 1, '', 0, 1, 1, NULL, NULL), + (@option_group_id_recent, {localize}'{ts escape="sql"}Participants{/ts}'{/localize}, 'Participant', 'Participant', NULL, NULL, 0, 1, '', 0, 1, 1, NULL, NULL), + (@option_group_id_recent, {localize}'{ts escape="sql"}Memberships{/ts}'{/localize}, 'Membership', 'Membership', NULL, NULL, 0, 1, '', 0, 1, 1, NULL, NULL), + (@option_group_id_recent, {localize}'{ts escape="sql"}Pledges{/ts}'{/localize}, 'Pledge', 'Pledge', NULL, NULL, 0, 1, '', 0, 1, 1, NULL, NULL), + (@option_group_id_recent, {localize}'{ts escape="sql"}Events{/ts}'{/localize}, 'Event', 'Event', NULL, NULL, 0, 1, '', 0, 1, 1, NULL, NULL), + (@option_group_id_recent, {localize}'{ts escape="sql"}Campaigns{/ts}'{/localize}, 'Campaign', 'Campaign', NULL, NULL, 0, 1, '', 0, 1, 1, NULL, NULL); -- 2.25.1