Skip to content
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#2588 - Crash when sending to 3+ email recipients with an attachment in 5.36+ #20222

Merged
merged 1 commit into from
May 5, 2021

Conversation

demeritcowboy
Copy link
Contributor

@demeritcowboy demeritcowboy commented May 5, 2021

Overview

https://lab.civicrm.org/dev/core/-/issues/2588

Tentative fix - I haven't fully tested it but wanted to put it up given the timing.

Before

  1. Create an email activity (not a mass mailing) to 3 or more people.
  2. Add one or more attachments.
  3. Send the email.
  4. Crashes while sending to the 3rd recipient.

After

No crash

Technical Details

array_merge_recursive ends up creating an array for the id on the 3rd iteration. $attachmentFileIds will look something like this on the 2nd and all following iterations:

array(
 'attachFile_1' => array('id' => 46),
 'attachFile_2' => array('id' => 47),
)

So there's no merge the first time, and on the 2nd time $attachments doesn't have an id member yet so the merge is fine. But then just before it's merged into $attachments on the 3rd time $attachments looks something like:

array(
  'attachFile_1' => array(
    'uri' => 'something',
    'type' => 'something',
    // ...
    'id' => 46,
  ),
  'attachFile_2' => array(
    'uri' => 'something',
    'type' => 'something',
    // ...
    'id' => 47,
  ),
)

so it converts the id member into e.g. array(46, 46) because that's what array_merge_recursive does.

Comments

@civibot
Copy link

civibot bot commented May 5, 2021

(Standard links)

@civibot civibot bot added the 5.37 label May 5, 2021
@eileenmcnaughton
Copy link
Contributor

Thanks for jumping on this @demeritcowboy - do you know when it regressed?

@demeritcowboy
Copy link
Contributor Author

It started in 5.36.0 - it's from #18299

@totten
Copy link
Member

totten commented May 5, 2021

  • General standards
    • (r-explain) Pass
    • (r-user) Pass
    • (r-doc) Pass
    • (r-run) Pass: I've r-run with and without the patch - reproduced the original problem and confirmed this fixes it. Also, with the fixed branch, I did some r-run with various permutations of:
      * Initiating the email from "Search Results" and from "View Contact"
      * Sending to 1, 2, 3, and 5 contacts
      * Attaching 0, 1, and 2 files
      All looked good. ✅
  • Developer standards

@totten totten merged commit 727fb9f into civicrm:5.37 May 5, 2021
@demeritcowboy
Copy link
Contributor Author

Thanks for testing!
So it's still an unknown with 4 recipients but that's ok I'm on good speaking terms with the number 4 if something comes up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants