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"

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mvogel created an issue. See original summary.

mvogel’s picture

Issue summary: View changes
sukanya.ramakrishnan’s picture

@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

raman.b’s picture

Version: 8.x-1.0-alpha2 » 8.x-1.0-beta2

To 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))

raman.b’s picture

Status: Active » Needs review
FileSize
1.34 KB
sukanya.ramakrishnan’s picture

Thanks 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

sukanya.ramakrishnan’s picture

Also, since this error was not caught by tests, looks like we are missing test coverage. Patch with a test would be great!

gaurav.kapoor’s picture

Status: Needs review » Fixed

Let's pick test cases in seperate issue.

gaurav.kapoor’s picture

Status: Fixed » Needs work

My bad. Pushed this by mistake. @ramanbatra1709 can you add the correct patch?

manishsaharan’s picture

Issue Fixed. Need Approval

manishsaharan’s picture

Status: Needs work » Needs review
sukanya.ramakrishnan’s picture

Hmm, 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

gnuget’s picture

We 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.

The last submitted patch, 14: 2874843-14-test-only.patch, failed testing. View results

mlncn’s picture

Status: Needs review » Reviewed & tested by the community

We've been using this successfully for more than a month now.

  • gnuget authored 17ea419 on 8.x-1.x
    Issue #2874843 by gnuget, ramanbatra1709, manishsaharan29497, sukanya....
gaurav.kapoor’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, everyone for working on this.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.