Problem/Motivation
When the module was not able to retrieve any subscription lists, it shows the message
The subscription service is currently unavailable. Please try again later.
to the user.
Besides, that that message could be misleading, because it's quite generic, the code execution in the buildForm() method continues and builds a subscription form with an undefined $list->id in its wrapper. Through the mergevars processing afterwards all form elements will be disabled, to there is no further business logic affected.
The notice thrown is
Notice: Trying to get property of non-object in Drupal\mailchimp_signup\Form\MailchimpSignupPageForm->buildForm() (line 119 of /modules/contrib/mailchimp/modules/mailchimp_signup/src/Form/MailchimpSignupPageForm.php).
Proposed resolution
Do a proper isset check, before adding the $list-id to the wrapper element, to avoid the notices.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | mailchimp-undefined_mergevar_form_wrapper-2776765-6.patch | 799 bytes | szeidler |
| #2 | mailchimp-undefined_mergevar_form_wrapper-2776765-2.patch | 644 bytes | szeidler |
Comments
Comment #2
szeidler commentedAttached patch for a conditional list-id wrapper. I'm open for other fixes here, the important thing is to get rid of the notice and get the logs clean for the important entries.
Comment #4
amytswan commentedThanks for finding this issue and proposing a patch, @szeidler! This patch looked like a good way to handle this issue, so I committed it.
Comment #5
idebr commentedThis change does not actually solve the problem, since the new variable is not applied to the template.
Comment #6
szeidler commentedOuch, you're absolutely right. Attached an additional patch to fix the issue, based on the current dev, which has the "broken" patch already included.
Comment #7
asrobI've successfully applied this patch and looks good to me. RTBC'ed!
Comment #8
gnugetThis was committed 3 months ago... wondering why it is still as RTBC?
Comment #9
szeidler commentedThe initial patch, which was committed, didn't solve the problem correctly. Therefore the issue was reopened again and an additional patch in #6 went rtbc.
Comment #11
greg boggsThanks for all the work on this one folks.
Comment #13
greg boggsComment #14
grantkrugerDue to us having a mailchimp signup form in our site footer users to our site get this message on every page even though they probably are not signing up. They get the message repeatedly on multiple pages/refreshes even if they x it out several times. This happens for some minutes after the caches get flushed. Any news on when these changes are getting released to a new recommended version or do I need to go with the dev version or the patches to fix the problem?