Problem/Motivation

When displaying the subscribe form, an error is thrown:

The website encountered an unexpected error. Please try again later.
Error: Cannot use object of type stdClass as array in Drupal\mailchimp_lists\Form\MailchimpListsSubscribeForm->buildForm() (line 104 of modules/contrib/mailchimp/modules/mailchimp_lists/src/Form/MailchimpListsSubscribeForm.php).

Drupal\mailchimp_lists\Form\MailchimpListsSubscribeForm->buildForm()
call_user_func_array() (Line: 532)
Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 278)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 219)
Drupal\Core\Form\FormBuilder->getForm() (Line: 126)
Drupal\mailchimp_lists\Plugin\Field\FieldFormatter\MailchimpListsFieldSubscribeFormatter->viewElements() (Line: 89)
Drupal\Core\Field\FormatterBase->view() (Line: 263)
Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple() (Line: 351)
Drupal\Core\Entity\EntityViewBuilder->buildComponents() (Line: 293)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple() (Line: 250)
Drupal\Core\Entity\EntityViewBuilder->build()
call_user_func_array() (Line: 100)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 781)
Drupal\Core\Render\Renderer->doCallback() (Line: 372)
Drupal\Core\Render\Renderer->doRender() (Line: 200)
Drupal\Core\Render\Renderer->render() (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
call_user_func() (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 156)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 57)
Drupal\Core\StackMiddleware\Session->handle() (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 708)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Steps to reproduce

  • Create a field of type `field_subscribe` for user entities,
  • in the form display use the `form subscribe` formatter
  • Call the user's profile

Proposed resolution

MailchimpListsSubscribeForm::build assumes the the list of list contains an array of array, but in fact an array of objects is returned by `mailchimp_get_list`

This seems to be the only location where `$mc_lists` incorrectely. The only point that worries me, is: This seems to be a very basic function, why isn't this addressed before, or did I miss the issue?

Remaining tasks

Fix it and supply patch.

User interface changes

-NONE-

API changes

-NONE-

Data model changes

-NONE-

Issue fork mailchimp-3300173

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mmbk created an issue. See original summary.

mmbk’s picture

Assigned: mmbk » Unassigned
Status: Active » Needs review

xenophyle made their first commit to this issue’s fork.

xenophyle’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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