diff --git a/CRM/Upgrade/Incremental/php/FiveFiftyThree.php b/CRM/Upgrade/Incremental/php/FiveFiftyThree.php index fcd688ef6bdf..8d952584f21c 100644 --- a/CRM/Upgrade/Incremental/php/FiveFiftyThree.php +++ b/CRM/Upgrade/Incremental/php/FiveFiftyThree.php @@ -21,6 +21,33 @@ */ class CRM_Upgrade_Incremental_php_FiveFiftyThree extends CRM_Upgrade_Incremental_Base { + public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) { + if ($rev === '5.53.alpha1') { + $postUpgradeMessage .= '
'; + } + } + /** * Upgrade step; adds tasks including 'runSql'. * @@ -29,6 +56,38 @@ class CRM_Upgrade_Incremental_php_FiveFiftyThree extends CRM_Upgrade_Incremental */ public function upgrade_5_53_alpha1($rev): void { $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); + $this->addTask('Replace %A specifier in date settings.', 'replacePercentA'); + } + + public static function replacePercentA($ctx): bool { + foreach ([ + 'dateformatDatetime', + 'dateformatFull', + 'dateformatPartial', + 'dateformatYear', + 'dateformatTime', + 'dateformatFinancialBatch', + 'dateformatshortdate', + ] as $setting) { + $value = \Civi::settings()->get($setting); + if ($value && (strpos($value, '%A') !== FALSE)) { + $value = strtr($value, ['%A' => '%P']); + \Civi::settings()->set($setting, $value); + } + } + return TRUE; + } + + public static function getTemplatesUsingPercentA(): array { + $usages = []; + // is_default has weird meaning - it means the one currently in use, not the default distributed with civi (which is is_reserved). + // The "NOT LIKE" part is necessary to avoid false positives because the + // event receipt uses it (correctly) with date_format. + $dao = CRM_Core_DAO::executeQuery("SELECT id, msg_title FROM civicrm_msg_template WHERE is_default = 1 AND ((msg_html LIKE BINARY '%\\%A%' AND msg_html NOT LIKE BINARY '%date_format:\"\\%A\"%') OR (msg_text LIKE BINARY '%\\%A%' AND msg_text NOT LIKE BINARY '%date_format:\"\\%A\"%') OR (msg_subject LIKE BINARY '%\\%A%' AND msg_subject NOT LIKE BINARY '%date_format:\"\\%A\"%'))"); + while ($dao->fetch()) { + $usages[$dao->id] = $dao->msg_title; + } + return $usages; } }