-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dev/core#2463 - Adjust returned list of activity ids when sending emails since it changes in 5.36+ #19873
dev/core#2463 - Adjust returned list of activity ids when sending emails since it changes in 5.36+ #19873
Conversation
(Standard links)
|
@demeritcowboy does this need to be against 5.36? |
The two most straightforward choices seem to be:
|
@demeritcowboy doesn't sound like a compelling case for putting it against 5.36 if it increases the risk of breakage :-) I'll take a look in a bit |
They'll be broken either way in 5.36, just different kinds of broken. The fact that some extensions call sendEmail and act on the resulting activity was unnoticed/unforseen during the change to store the replacement values of tokens in separate activities per recipient. |
CRM/Activity/BAO/Activity.php
Outdated
@@ -1017,7 +1017,7 @@ public static function createEmailActivity($sourceContactID, $subject, $html, $t | |||
* @param int $caseId | |||
* | |||
* @return array | |||
* ( sent, activityId) if any email is sent and activityId | |||
* ( sent, activityIds) if any email is sent and the corresponding activity ids |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is not clear, I think an improvement would be:
* ( sent, activityIds) if any email is sent and the corresponding activity ids | |
* [ bool sent, array activityIds ] if any email is sent and the corresponding activity ids |
I'm also not sure it's correct. $sent
is initialised to []
but then set FALSE
and maybe TRUE
in the loop; so it's only referring to the last loop iteration. Seems the same problem as for $activityId(s)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to look at the $sent issue separately since it's been like that since 2009. Kudos for noticing.
@artfulrobot thanks for taking a look - I'm happy to merge this when you are happy with it |
88a5146
to
13ecf77
Compare
Addressed the other comments and added an explicit test for the returned ids. |
Looks good to me, thanks @demeritcowboy |
Thanks for the review! |
Thanks @artfulrobot & @demeritcowboy |
Overview
https://lab.civicrm.org/dev/core/-/issues/2463
Followup to #19826 and towards making the recorded activity ids available to hooks.
I'm a bit conflicted about changing the signature for a public static function. But at the same time any extensions that call this function and act on the single activity id it returns are now doing it wrong as of 5.36, since they're missing all the other activity ids. Universe suggests there's a small handful. An alternative would be to keep the signature and provide some other way to get at the ids, which doesn't seem hard, but does it really help the existing extensions?
Before
In 5.35 and earlier, only one activity was recorded when there were multiple recipients when sending a (non-bulk) email. In 5.36 it now records multiple activities, but the code still returns just the last activity id to its caller.
After
Returns all the ids.
Technical Details
One thing that came up during the original review of the multiple activities PR had to do with any scheduled followups. I've left that as-is so it still only links the followup to one of the activity ids. The original quote:
Comments
This doesn't do anything with the returned ids yet. Making it available to hooks would be a followup.
There's some coverage for multiple recipients at testSendEmailWillReplaceTokensUniquelyForEachContact. But I should probably add something to explicitly test the returned values.