Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The form builder for MailchimpListsSubscribeForm expects an array from mailchimp_get_list(), and is real sad when it gets an object.
Error: Cannot use object of type stdClass as array in Drupal\mailchimp_lists\Form\MailchimpListsSubscribeForm->buildForm() (line 83 of
/var/www/drupal/public_html/web/modules/contrib/mailchimp/modules/mailchimp_lists/src/Form/MailchimpListsSubscribeForm.php) #0
[internal function]: Drupal\mailchimp_lists\Form\MailchimpListsSubscribeForm->buildForm(Array, Object(Drupal\Core\Form\FormState))
#1 /var/www/drupal/public_html/web/core/lib/Drupal/Core/Form/FormBuilder.php(514): call_user_func_array(Array, Array)
#2 /var/www/drupal/public_html/web/core/lib/Drupal/Core/Form/FormBuilder.php(271):
Drupal\Core\Form\FormBuilder->retrieveForm('mailchimp_lists...', Object(Drupal\Core\Form\FormState))
#3 /var/www/drupal/public_html/web/core/lib/Drupal/Core/Form/FormBuilder.php(212):
Drupal\Core\Form\FormBuilder->buildForm('mailchimp_lists...', Object(Drupal\Core\Form\FormState))
#4
/var/www/drupal/public_html/web/modules/contrib/mailchimp/modules/mailchimp_lists/src/Plugin/Field/FieldFormatter/MailchimpListsFieldS
ubscribeFormatter.php(90): Drupal\Core\Form\FormBuilder->getForm(Object(Drupal\mailchimp_lists\Form\MailchimpListsSubscribeForm))
#5 /var/www/drupal/public_html/web/core/lib/Drupal/Core/Field/FormatterBase.php(80):
Drupal\mailchimp_lists\Plugin\Field\FieldFormatter\MailchimpListsFieldSubscribeFormatter->viewElements(Object(Drupal\Core\Field\FieldI
temList), 'en')
#6 /var/www/drupal/public_html/web/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php(259):
Drupal\Core\Field\FormatterBase->view(Object(Drupal\Core\Field\FieldItemList), 'en')
#7 /var/www/drupal/public_html/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(320):
Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array)
#8 /var/www/drupal/public_html/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(263):
Drupal\Core\Entity\EntityViewBuilder->buildComponents(Array, Array, Array, 'full')
#9 /var/www/drupal/public_html/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(220):
Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array)
#10 [internal function]: Drupal\Core\Entity\EntityViewBuilder->build(Array)
#11 /var/www/drupal/public_html/web/core/lib/Drupal/Core/Render/Renderer.php(378): call_user_func(Array, Array)
#12 /var/www/drupal/public_html/web/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\Core\Render\Renderer->doRender(Array, false)
#13 /var/www/drupal/public_html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(226):
Drupal\Core\Render\Renderer->render(Array, false)
#14 /var/www/drupal/public_html/web/core/lib/Drupal/Core/Render/Renderer.php(576):
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#15 /var/www/drupal/public_html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(227):
Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#16 /var/www/drupal/public_html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(117):
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object(Symfony\Component\HttpFoundation\Request),
Object(Drupal\Core\Routing\CurrentRouteMatch))
#17 /var/www/drupal/public_html/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90):
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request),
Object(Drupal\Core\Routing\CurrentRouteMatch))
#18 /var/www/drupal/public_html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(108):
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\Component\HttpKernel\Event\GetResponseForContr
ollerResultEvent), 'kernel.view', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#19 /var/www/drupal/public_html/vendor/symfony/http-kernel/HttpKernel.php(158):
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view',
Object(Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent))
#20 /var/www/drupal/public_html/vendor/symfony/http-kernel/HttpKernel.php(68):
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#21 /var/www/drupal/public_html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57):
Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /var/www/drupal/public_html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47):
Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /var/www/drupal/public_html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(99):
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /var/www/drupal/public_html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(78):
Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /var/www/drupal/public_html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47):
Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /var/www/drupal/public_html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50):
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /var/www/drupal/public_html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23):
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /var/www/drupal/public_html/web/core/lib/Drupal/Core/DrupalKernel.php(657):
Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 /var/www/drupal/public_html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#30 {main}.
Comment | File | Size | Author |
---|---|---|---|
#4 | 2931408-4-list-form-cant-array.patch | 1.34 KB | gugalamaciek |
Comments
Comment #2
ZenDoodles CreditAttribution: ZenDoodles as a volunteer and commentedSince I do not know the implications here, this is just a quick and dirty fix so we stop having 500 errors on some user pages.
Note: there's another place in the buildForm() method around line 111 which also thinks it's got an array and will probably fail hard in some cases too. Someone who knows more about the code will probably want to look at *why* this is broken and fix it f'reals.
Comment #3
Abhinand Gokhala K CreditAttribution: Abhinand Gokhala K commentedFacing the same issue in Drupal 9.
Comment #4
gugalamaciek CreditAttribution: gugalamaciek at Government of Flanders commentedI found one more place which tries to use $mc_list as array, while it's object. Patch attached.