Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
extensions
cc.tadpole.petitionemail
Commits
64f217f4
Commit
64f217f4
authored
Dec 02, 2014
by
Jamie McClelland
Browse files
more tests to ensure we don't get upgrade conflicts.
parent
ae70c007
Changes
1
Hide whitespace changes
Inline
Side-by-side
CRM/Petitionemail/Upgrader.php
View file @
64f217f4
...
...
@@ -35,10 +35,15 @@ class CRM_Petitionemail_Upgrader extends CRM_Petitionemail_Upgrader_Base {
$sql
=
"DESC civicrm_petition_email"
;
$dao
=
CRM_Core_DAO
::
executeQuery
(
$sql
);
$needs_upgrade
=
TRUE
;
$needs_transfer
=
FALSE
;
while
(
$dao
->
fetch
())
{
if
(
$dao
->
Field
==
'recipients'
)
{
$needs_upgrade
=
FALSE
;
}
if
(
$dao
->
Field
==
'recipient_email'
)
{
$needs_transfer
=
TRUE
;
}
}
if
(
$needs_upgrade
)
{
...
...
@@ -49,16 +54,18 @@ class CRM_Petitionemail_Upgrader extends CRM_Petitionemail_Upgrader_Base {
}
// Now transfer the data to the new tables
$sql
=
"SELECT petition_id, recipient_email, recipient_name FROM civicrm_petition_email"
;
$dao
=
CRM_Core_DAO
::
executeQuery
(
$sql
);
while
(
$dao
->
fetch
())
{
$target
=
'"'
.
$dao
->
recipient_name
.
'" <'
.
$dao
->
recipient_email
.
'>'
;
$sql
=
"UPDATE civicrm_petition_email SET recipients = %0 WHERE petition_id = %1"
;
$params
=
array
(
0
=>
array
(
$target
,
'String'
),
1
=>
array
(
$dao
->
petition_id
,
'Integer'
),
);
CRM_Core_DAO
::
executeQuery
(
$sql
,
$params
);
if
(
$needs_transfer
)
{
$sql
=
"SELECT petition_id, recipient_email, recipient_name FROM civicrm_petition_email"
;
$dao
=
CRM_Core_DAO
::
executeQuery
(
$sql
);
while
(
$dao
->
fetch
())
{
$target
=
'"'
.
$dao
->
recipient_name
.
'" <'
.
$dao
->
recipient_email
.
'>'
;
$sql
=
"UPDATE civicrm_petition_email SET recipients = %0 WHERE petition_id = %1"
;
$params
=
array
(
0
=>
array
(
$target
,
'String'
),
1
=>
array
(
$dao
->
petition_id
,
'Integer'
),
);
CRM_Core_DAO
::
executeQuery
(
$sql
,
$params
);
}
}
// Now drop/add fields.
if
(
!
$this
->
executeSqlFile
(
'sql/Petitionemail_1001_upgrade.sql'
))
return
FALSE
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment