Skip to content

Commit

Permalink
Fix warnings on upgrade when non-core message templates exist
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Sep 22, 2022
1 parent 28cc21b commit 5c2c4a1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions CRM/Upgrade/Incremental/MessageTemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,15 @@ public static function updateReservedAndMaybeDefaultTemplates(CRM_Queue_TaskCont
// This has to come first otherwise it would be checking against is_reserved we already updated.
$uneditedTemplates = self::getUneditedTemplates();

$dao = CRM_Core_DAO::executeQuery("SELECT id, workflow_id, workflow_name FROM civicrm_msg_template WHERE is_reserved=1");
$dao = CRM_Core_DAO::executeQuery('SELECT id, workflow_id, workflow_name FROM civicrm_msg_template WHERE is_reserved=1');
while ($dao->fetch()) {
foreach (['html', 'text', 'subject'] as $type) {
$content = file_get_contents(\Civi::paths()->getPath('[civicrm.root]/xml/templates/message_templates/' . $dao->workflow_name . '_' . $type . '.tpl'));
$filePath = \Civi::paths()->getPath('[civicrm.root]/xml/templates/message_templates/' . $dao->workflow_name . '_' . $type . '.tpl');
if (!file_exists($filePath)) {
// The query may have picked up some non-core templates that will not have files to find.
continue;
}
$content = file_get_contents($filePath);
if ($content) {
CRM_Core_DAO::executeQuery(
"UPDATE civicrm_msg_template SET msg_{$type} = %1 WHERE id = %2", [
Expand Down

0 comments on commit 5c2c4a1

Please sign in to comment.