From 9c0712453e79b66073936251343fa9fdc5595d5b Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 24 Mar 2022 19:05:12 -0700 Subject: [PATCH] dev/core#2122 - TimezoneRevertTrait - Downgrade should use same TZ as prior upgrade --- .../Incremental/php/TimezoneRevertTrait.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/CRM/Upgrade/Incremental/php/TimezoneRevertTrait.php b/CRM/Upgrade/Incremental/php/TimezoneRevertTrait.php index 3df1ced2f2..25f3c7f650 100644 --- a/CRM/Upgrade/Incremental/php/TimezoneRevertTrait.php +++ b/CRM/Upgrade/Incremental/php/TimezoneRevertTrait.php @@ -95,10 +95,20 @@ trait CRM_Upgrade_Incremental_php_TimezoneRevertTrait { */ public static function revertEventDates(CRM_Queue_TaskContext $ctx): bool { // We only run if the field is timestamp, so don't need to check about that. - CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_event` MODIFY COLUMN `start_date` datetime DEFAULT NULL COMMENT 'Date and time that event starts.'"); - CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_event` MODIFY COLUMN `end_date` datetime DEFAULT NULL COMMENT 'Date and time that event ends. May be NULL if no defined end date/time'"); - CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_event` MODIFY COLUMN `registration_start_date` datetime DEFAULT NULL COMMENT 'Date and time that online registration starts.'"); - CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_event` MODIFY COLUMN `registration_end_date` datetime DEFAULT NULL COMMENT 'Date and time that online registration ends.'"); + + // The original 5.47.alpha1 upgrade was executed with SQL helpers in CRM_Utils_File, which use + // a separate DSN/session. We need to use the same interface so that the `@@time_zone` is consistent + // with the prior update. + + $sql = "ALTER TABLE `civicrm_event` + MODIFY COLUMN `start_date` datetime DEFAULT NULL COMMENT 'Date and time that event starts.', + MODIFY COLUMN `end_date` datetime DEFAULT NULL COMMENT 'Date and time that event ends. May be NULL if no defined end date/time', + MODIFY COLUMN `registration_start_date` datetime DEFAULT NULL COMMENT 'Date and time that online registration starts.', + MODIFY COLUMN `registration_end_date` datetime DEFAULT NULL COMMENT 'Date and time that online registration ends.';"; + + $upgrade = new CRM_Upgrade_Form(); + $upgrade->source($sql, TRUE); + return TRUE; } -- 2.25.1