From 6c2accd9d69ea59b3b926aed23455d407059d34c Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 25 Mar 2022 02:39:36 -0700 Subject: [PATCH] dev/core#2122 - TimezoneRevertTrait - Failsafe to opt-out of TZ converter --- .../Incremental/php/TimezoneRevertTrait.php | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/CRM/Upgrade/Incremental/php/TimezoneRevertTrait.php b/CRM/Upgrade/Incremental/php/TimezoneRevertTrait.php index 6e95d0e678..f27d734fbc 100644 --- a/CRM/Upgrade/Incremental/php/TimezoneRevertTrait.php +++ b/CRM/Upgrade/Incremental/php/TimezoneRevertTrait.php @@ -63,13 +63,22 @@ trait CRM_Upgrade_Incremental_php_TimezoneRevertTrait { public function addEventTzTasks(): void { if (self::areEventsUsingTimestamp()) { - $this->addTask('Add temporary backup start_date to civicrm_event', 'addColumn', 'civicrm_event', 'start_date_ts_bak', "timestamp NULL DEFAULT NULL COMMENT 'For troubleshooting upgrades post 5.47. Can drop this column if no issues.'"); - $this->addTask('Add temporary backup end_date to civicrm_event', 'addColumn', 'civicrm_event', 'end_date_ts_bak', "timestamp NULL DEFAULT NULL COMMENT 'For troubleshooting upgrades post 5.47. Can drop this column if no issues.'"); - $this->addTask('Add temporary backup registration_start_date to civicrm_event', 'addColumn', 'civicrm_event', 'registration_start_date_ts_bak', "timestamp NULL DEFAULT NULL COMMENT 'For troubleshooting upgrades post 5.47. Can drop this column if no issues.'"); - $this->addTask('Add temporary backup registration_end_date to civicrm_event', 'addColumn', 'civicrm_event', 'registration_end_date_ts_bak', "timestamp NULL DEFAULT NULL COMMENT 'For troubleshooting upgrades post 5.47. Can drop this column if no issues.'"); - $this->addTask('Backup CiviEvent times', 'fillBackupEventDates'); - $this->addTask('Revert CiviEvent times', 'revertEventDates'); - $this->addTask('Adapt CiviEvent times', 'convertModifiedEvents'); + $actions = getenv('CIVICRM_TZ_REVERT') + ? explode(',', getenv('CIVICRM_TZ_REVERT')) + : ['backup', 'revert', 'adapt']; + if (in_array('backup', $actions)) { + $this->addTask('Add temporary backup start_date to civicrm_event', 'addColumn', 'civicrm_event', 'start_date_ts_bak', "timestamp NULL DEFAULT NULL COMMENT 'For troubleshooting upgrades post 5.47. Can drop this column if no issues.'"); + $this->addTask('Add temporary backup end_date to civicrm_event', 'addColumn', 'civicrm_event', 'end_date_ts_bak', "timestamp NULL DEFAULT NULL COMMENT 'For troubleshooting upgrades post 5.47. Can drop this column if no issues.'"); + $this->addTask('Add temporary backup registration_start_date to civicrm_event', 'addColumn', 'civicrm_event', 'registration_start_date_ts_bak', "timestamp NULL DEFAULT NULL COMMENT 'For troubleshooting upgrades post 5.47. Can drop this column if no issues.'"); + $this->addTask('Add temporary backup registration_end_date to civicrm_event', 'addColumn', 'civicrm_event', 'registration_end_date_ts_bak', "timestamp NULL DEFAULT NULL COMMENT 'For troubleshooting upgrades post 5.47. Can drop this column if no issues.'"); + $this->addTask('Backup CiviEvent times', 'fillBackupEventDates'); + } + if (in_array('revert', $actions)) { + $this->addTask('Revert CiviEvent times', 'revertEventDates'); + } + if (in_array('adapt', $actions)) { + $this->addTask('Adapt CiviEvent times', 'convertModifiedEvents'); + } } } -- 2.25.1