From: Tim Otten Date: Wed, 23 Mar 2022 04:46:33 +0000 (-0700) Subject: dev/core#2122 - TimezoneRevertTrait - Split out messaging across bullets X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=daaa02a5762185ef424021c6d32872d9f9823014;p=civicrm-core.git dev/core#2122 - TimezoneRevertTrait - Split out messaging across bullets --- diff --git a/CRM/Upgrade/Incremental/php/TimezoneRevertTrait.php b/CRM/Upgrade/Incremental/php/TimezoneRevertTrait.php index b5e7e13a62..1ee8a8a152 100644 --- a/CRM/Upgrade/Incremental/php/TimezoneRevertTrait.php +++ b/CRM/Upgrade/Incremental/php/TimezoneRevertTrait.php @@ -20,10 +20,35 @@ trait CRM_Upgrade_Incremental_php_TimezoneRevertTrait { public function createEventTzPreUpgradeMessage(): string { if (self::areEventsUsingTimestamp() && self::areThereAnyCiviEvents()) { - return '
' . ts('CiviEvent Timezones') . '
'; + $timezoneStats = $this->getTimezoneStats(); + return '
' . ts('CiviEvent Timezone Rollback') . '
'; } return ''; } @@ -99,20 +124,13 @@ trait CRM_Upgrade_Incremental_php_TimezoneRevertTrait { return (bool) CRM_Core_DAO::singleValueQuery('SELECT COUNT(id) FROM civicrm_event'); } - /** - * Return the event_tz that is used most often. The idea being that if they - * didn't change too much after upgrading to 5.47 this will be the timezone - * of the account that was used to do the original upgrade to 5.47. - * @return string - */ - private static function getMajorityTimezone(): string { - $dao = CRM_Core_DAO::executeQuery('SELECT event_tz, COUNT(event_tz) AS cnt FROM civicrm_event GROUP BY event_tz ORDER BY COUNT(event_tz) DESC LIMIT 1'); - if ($dao->fetch()) { - return $dao->event_tz; + private function getTimezoneStats(): array { + $dao = CRM_Core_DAO::executeQuery('SELECT event_tz, COUNT(*) AS `count` FROM civicrm_event GROUP BY event_tz ORDER BY COUNT(event_tz) DESC'); + $r = []; + while ($dao->fetch()) { + $r[] = ['name' => $dao->event_tz ?: ts('Empty'), 'count' => $dao->count]; } - // This shouldn't happen, because our function only gets called if there is - // at least one event in the system. - return ''; + return $r; } }