mailchimp / wordpress

Add a Mailchimp signup form widget to your WordPress site.
https://wordpress.org/plugins/mailchimp/
GNU General Public License v2.0
1 stars 0 forks source link

If no list is selected, the form still shows but doesn't work correctly #53

Closed dkotter closed 2 months ago

dkotter commented 2 months ago

Describe the bug

While testing #51 (see https://github.com/mailchimp/wordpress/pull/51#issuecomment-2339008891) I ran into an issue in the following scenario:

  1. Either sign in with a new account or create a new account
  2. On the settings screen, verify no List is selected (should show -- Select A List --
  3. Create a new page and add the Mailchimp block to it
  4. Verify the form shows correctly on the front-end
  5. Try and submit the form with no information or with valid information
  6. If debug is on, you should get the following PHP warning: Undefined array key "field" in /mailchimp/lib/mailchimp/mailchimp.php on line 193

If I debug the response from the request, this is what I get:

{
["type"]=> string(54) "https://mailchimp.com/developer/marketing/docs/errors/"
["title"]=> string(18) "Resource Not Found"
["status"]=> int(404)
["detail"]=> string(42) "The requested resource could not be found."
["instance"]=> string(36) "redacted"
}

I think we can add better defensive programming here to ensure the value we want exists before we try and use it. But would also be ideal in this scenario to not allow the form at all if no valid list has been selected.

Steps to Reproduce

No response

Screenshots, screen recording, code snippet

No response

Environment information

No response

WordPress information

No response

Code of Conduct