Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I get a fatal error when choosing "Checkboxes" in admin/config/mass-contact/settings in "Field to use to display categories" and want to send a mail.
Fatal error: Call to a member function getRecipients() on a non-object in /home/rcpyv/www/modules/mass_contact/src/MassContact.php on line 198
You can reproduce this by using simplytest.me. I enabled "Mass Contact", "Mailsystem" and "Swift Mailer"
Comment | File | Size | Author |
---|---|---|---|
#14 | 2874843-14.patch | 3.05 KB | gnuget |
| |||
#14 | 2874843-14-test-only.patch | 1.64 KB | gnuget |
#11 | 2874843-11.patch | 607 bytes | manishsaharan |
| |||
#5 | 2874843-5.patch | 1.34 KB | raman.b |
|
Comments
Comment #2
mvogel CreditAttribution: mvogel commentedComment #3
sukanya.ramakrishnan CreditAttribution: sukanya.ramakrishnan at Workday, Inc. commented@mvogel,
I couldnt replicate this issue. tried with multiple number of categories (including zero).
Recently, category was made optional for sending a mass contact message. Quite a few changes were made relating to it. Please try using the latest dev version and let us know if the error still exists.
Thanks,
Sukanya
Comment #4
raman.b CreditAttribution: raman.b at OpenSense Labs commentedTo replicate the issue, go to Mass Contact Settings Form (/admin/config/mass-contact/settings), change the 'Field to use to display the categories' to 'Check boxes'. Then send mass email using /mass-contact without any categories selected and 'Send yourself a copy' as checked. Following error is logged:
Error: Call to a member function label() on null in Drupal\mass_contact\Form\MassContactMessageConfirmForm->buildForm() (line 138 of /var/www/html/drupal/modules/mass_contact/src/Form/MassContactMessageConfirmForm.php) #0 [internal function]: Drupal\mass_contact\Form\MassContactMessageConfirmForm->buildForm(Array, Object(Drupal\Core\Form\FormState))
Comment #5
raman.b CreditAttribution: raman.b at OpenSense Labs commentedComment #6
sukanya.ramakrishnan CreditAttribution: sukanya.ramakrishnan commentedThanks for the patch. I see that the expressions
array_filter($form_state->getValue('categories')
is being repeated. Can we put this in a local variable instead?Thanks,
Sukanya
Comment #7
sukanya.ramakrishnan CreditAttribution: sukanya.ramakrishnan commentedAlso, since this error was not caught by tests, looks like we are missing test coverage. Patch with a test would be great!
Comment #9
gaurav.kapoor CreditAttribution: gaurav.kapoor as a volunteer and commentedLet's pick test cases in seperate issue.
Comment #10
gaurav.kapoor CreditAttribution: gaurav.kapoor as a volunteer and commentedMy bad. Pushed this by mistake. @ramanbatra1709 can you add the correct patch?
Comment #11
manishsaharan CreditAttribution: manishsaharan commentedIssue Fixed. Need Approval
Comment #12
manishsaharan CreditAttribution: manishsaharan commentedComment #13
sukanya.ramakrishnan CreditAttribution: sukanya.ramakrishnan commentedHmm, both patches submitted are different. @manishsaharan29497 Did u mean to combine both patches ?
I would really like test coverage on this fix . Will try to work on it this weekend. Thanks!
Thanks,
Sukanya
Comment #14
gnugetWe found this bug in one of our projects today and we created #3125825: Fatal error when a category isn't selected (!?!) while debugging it, glad to see that this was already reported.
I address the comment at #6 and I modified a bit one of the tests to use the checkboxes instead of the select so this can be indeed tested.
New patch attached.
Comment #16
mlncn CreditAttribution: mlncn at Agaric for Drutopia, Cambridge, Massachusetts Family Policy Council, Find It Cambridge commentedWe've been using this successfully for more than a month now.
Comment #18
gaurav.kapoor CreditAttribution: gaurav.kapoor as a volunteer and at Axelerant for Drupal India Association commentedThanks, everyone for working on this.