Problem/Motivation

When submitting a signup form for a single list while multiple lists are available in the account, the form validation will consistently return the error "Please select at least one list to subscribe to.", even though list checkboxes are not shown to the user.

Proposed resolution

It is plausible the user wants to subscribe to the single configured list, hence no checkboxes being shown. There is however an error in the validation method. The size of $signup->mc_lists is checked to be bigger than 1. When multiple lists are available, the array is always bigger than one. The values in the array are either the list ID or 0, the latter being the case when the list is not configured for subscription. Thus, as also done in the submit method, the array should be passed through array_filter() before count().

Remaining tasks

-none-

User interface changes

-none-

API changes

-none-

Data model changes

-none-

Comments

DietrichM created an issue. See original summary.

dietr_ch’s picture

Attached patch with fix as described in the solution.

dietr_ch’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: mailchimp-signup_single_list_error-2654978-2.patch, failed testing.

The last submitted patch, 2: mailchimp-signup_single_list_error-2654978-2.patch, failed testing.

The last submitted patch, 2: mailchimp-signup_single_list_error-2654978-2.patch, failed testing.

The last submitted patch, 2: mailchimp-signup_single_list_error-2654978-2.patch, failed testing.

The last submitted patch, 2: mailchimp-signup_single_list_error-2654978-2.patch, failed testing.

dietr_ch’s picture

Status: Needs work » Needs review
StatusFileSize
new817 bytes

I just noticed the issue does not appear anymore since commit d4a8a102e9a03779af660c1bf8365185dce91ed8. However this has disabled the list checkbox validation altogether: when the form displays checkboxes and none is checked, the form will no longer show "Please select at least one list to subscribe to".

I rerolled the patched to the latest dev version before reverting above commit, so the validation works as expected.

Status: Needs review » Needs work

The last submitted patch, 9: mailchimp-signup_single_list_error-2654978-9.patch, failed testing.

The last submitted patch, 9: mailchimp-signup_single_list_error-2654978-9.patch, failed testing.

The last submitted patch, 9: mailchimp-signup_single_list_error-2654978-9.patch, failed testing.

The last submitted patch, 9: mailchimp-signup_single_list_error-2654978-9.patch, failed testing.

The last submitted patch, 9: mailchimp-signup_single_list_error-2654978-9.patch, failed testing.

dietr_ch’s picture

Status: Needs work » Needs review
henk’s picture

I have the same problem. PHP 7 and PHP 5.5. I will review your patch now.

henk’s picture

I see that problem is not in the validation but creation of form.

Line 79

<?php
    if ($lists_count > 1) {
?>

If $lists_count is array with one value will not pass the if. In my opinion should more that 0:

Line 79

<?php
    if ($lists_count > 0) {
?>

Also If we have only one mailchimp list '#checkbox' can be change to '#value'.

Status: Needs review » Needs work

The last submitted patch, 17: mailchimp-signup_single_list_error-2654978-17.patch, failed testing.

The last submitted patch, 17: mailchimp-signup_single_list_error-2654978-17.patch, failed testing.

The last submitted patch, 17: mailchimp-signup_single_list_error-2654978-17.patch, failed testing.

The last submitted patch, 17: mailchimp-signup_single_list_error-2654978-17.patch, failed testing.

The last submitted patch, 17: mailchimp-signup_single_list_error-2654978-17.patch, failed testing.

ruscoe’s picture

Status: Needs work » Postponed (maintainer needs more info)

I'm unable to reproduce this. Could you try with the current dev branch and update this issue if there's still a problem?

git clone --branch 8.x-1.x https://git.drupal.org/project/mailchimp.git

bart vanhoutte’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new1.29 KB

The issue seems to be fixed in the latest dev branch. However, the opposite has been introduced. If there's a form that has more than one list, validation passes even though no list has been selected.

asrob’s picture

Status: Needs review » Reviewed & tested by the community

I 've successfully applied this patch and looks good to me. That's why RTBC'ed!

  • amyvs committed c01d120 on 8.x-1.x authored by Bart Vanhoutte
    Issue #2654978 by dietr_ch, henk, Bart Vanhoutte, ruscoe, asrob: Signup...
amytswan’s picture

Status: Reviewed & tested by the community » Fixed

Thanks everyone for your contribution to this issue! I've pushed @Bart Vanhoutte's patch to the 8.x-1.x-dev branch - it's queued to go out in our next release.

Status: Fixed » Closed (fixed)

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