Problem/Motivation

When accessing the mail settings form on a newsletter type we are seeing the following error:

Error: Call to a member function formatPlural() on null in Drupal\simplenews\Form\MailSettingsForm->buildForm() (line 70 of modules/contrib/simplenews/src/Form/MailSettingsForm.php).

Steps to reproduce

Just go to /admin/config/services/simplenews/settings/mail and error will occur.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork simplenews-3318534

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

joel_osc created an issue. See original summary.

joel_osc’s picture

Here is a patch.

joel_osc’s picture

Status: Active » Needs review
adamps’s picture

Status: Needs review » Needs work

Thanks for the report. I believe the correct fix is much simpler, because all the code we need is on StringTranslationTrait, which is included by a parent class.

I don't hit the bug myself, and I don't see how you do😃. All the calls to $this->t should have initialised $this->stringTranslation.

Anyway it's still worth fixing. Instead of
$this->stringTranslation->formatPlural()
do
$this->formatPlural(

shivam_tiwari’s picture

Assigned: Unassigned » shivam_tiwari

shivam_tiwari’s picture

Assigned: shivam_tiwari » Unassigned
Status: Needs work » Needs review
adamps’s picture

Thanks for the patch. It looks good to me. It would be great if @joel_osc could confirm if the problem has been solved.

joel_osc’s picture

Patch works perfectly, +1 RBTC. Thank-you all.

adamps’s picture

Status: Needs review » Fixed

adamps’s picture

Great thanks for reporting back.

Status: Fixed » Closed (fixed)

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