Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
e36d9057
Commit
e36d9057
authored
5 years ago
by
Mathieu Lutfy
Committed by
bgm
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
marketing/civicrm-website#163
Mitigate potential upgrade errors on missing msg_templates
parent
e5ebe87d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CRM/Upgrade/Incremental/MessageTemplates.php
+13
-6
13 additions, 6 deletions
CRM/Upgrade/Incremental/MessageTemplates.php
with
13 additions
and
6 deletions
CRM/Upgrade/Incremental/MessageTemplates.php
+
13
−
6
View file @
e36d9057
...
...
@@ -267,7 +267,12 @@ class CRM_Upgrade_Incremental_MessageTemplates {
$content
=
file_get_contents
(
\Civi
::
paths
()
->
getPath
(
'[civicrm.root]/xml/templates/message_templates/'
.
$template
[
'name'
]
.
'_'
.
$template
[
'type'
]
.
'.tpl'
));
$templatesToUpdate
=
[];
if
(
!
empty
(
$workFlowID
))
{
$templatesToUpdate
[]
=
CRM_Core_DAO
::
singleValueQuery
(
"SELECT id FROM civicrm_msg_template WHERE workflow_id =
$workFlowID
AND is_reserved = 1"
);
// This could be empty if the template was deleted. It should not happen,
// but has been seen in the wild (ex: marketing/civicrm-website#163).
$id
=
CRM_Core_DAO
::
singleValueQuery
(
"SELECT id FROM civicrm_msg_template WHERE workflow_id =
$workFlowID
AND is_reserved = 1"
);
if
(
$id
)
{
$templatesToUpdate
[]
=
$id
;
}
$defaultTemplateID
=
CRM_Core_DAO
::
singleValueQuery
(
"
SELECT default_template.id FROM civicrm_msg_template reserved
LEFT JOIN civicrm_msg_template default_template
...
...
@@ -280,11 +285,13 @@ class CRM_Upgrade_Incremental_MessageTemplates {
$templatesToUpdate
[]
=
$defaultTemplateID
;
}
CRM_Core_DAO
::
executeQuery
(
"
UPDATE civicrm_msg_template SET msg_
{
$template
[
'type'
]
}
= %1 WHERE id IN ("
.
implode
(
','
,
$templatesToUpdate
)
.
")"
,
[
1
=>
[
$content
,
'String'
],
]
);
if
(
!
empty
(
$templatesToUpdate
))
{
CRM_Core_DAO
::
executeQuery
(
"
UPDATE civicrm_msg_template SET msg_
{
$template
[
'type'
]
}
= %1 WHERE id IN ("
.
implode
(
','
,
$templatesToUpdate
)
.
")"
,
[
1
=>
[
$content
,
'String'
],
]
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment