On a an existing site and a brand new Simplytest.me, attempting to create a new campaign results in unexpected error.
Both the existing site and the Simplytest.me are on Drupal 8.6.1.

Here's the logged error from Simplytest.me.

Error: Call to a member function getTranslationFromContext() on null in Drupal\Core\Entity\ContentEntityForm->initFormLangcodes() (line 313 of /home/dmriq/www/core/lib/Drupal/Core/Entity/ContentEntityForm.php) #0 /home/dmriq/www/core/lib/Drupal/Core/Entity/ContentEntityForm.php(284): Drupal\Core\Entity\ContentEntityForm->initFormLangcodes(Object(Drupal\Core\Form\FormState)) #1 /home/dmriq/www/core/lib/Drupal/Core/Entity/EntityForm.php(107): Drupal\Core\Entity\ContentEntityForm->init(Object(Drupal\Core\Form\FormState)) #2 [internal function]: Drupal\Core\Entity\EntityForm->buildForm(Array, Object(Drupal\Core\Form\FormState)) #3 /home/dmriq/www/core/lib/Drupal/Core/Form/FormBuilder.php(518): call_user_func_array(Array, Array) #4 /home/dmriq/www/core/lib/Drupal/Core/Form/FormBuilder.php(275): Drupal\Core\Form\FormBuilder->retrieveForm('mailchimp_campa...', Object(Drupal\Core\Form\FormState)) #5 /home/dmriq/www/core/lib/Drupal/Core/Controller/FormController.php(93): Drupal\Core\Form\FormBuilder->buildForm('mailchimp_campa...', Object(Drupal\Core\Form\FormState)) #6 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #7 /home/dmriq/www/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #8 /home/dmriq/www/core/lib/Drupal/Core/Render/Renderer.php(582): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #9 /home/dmriq/www/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #10 /home/dmriq/www/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #11 /home/dmriq/www/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #12 /home/dmriq/www/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #13 /home/dmriq/www/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #14 /home/dmriq/www/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #15 /home/dmriq/www/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #16 /home/dmriq/www/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #17 /home/dmriq/www/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #18 /home/dmriq/www/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #19 /home/dmriq/www/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #20 /home/dmriq/www/core/lib/Drupal/Core/DrupalKernel.php(665): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #21 /home/dmriq/www/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #22 {main}.

Not really sure where to start looking to fix this issue. Did something change in 8.6.x that needs to be addressed?

Comments

RedEight created an issue. See original summary.

stephen ollman’s picture

Same error here on fresh install with 8.6.0

redeight’s picture

I did notice that Automated Testing is failing for all php versions with Drupal 8.6. I'm not sure that is related though as it seems to be a failed profile install in the test system rather than something wrong with the Mailchimp module...

jaims-dev’s picture

Additional info that might be useful:

  • When enabling the campaigns module, it eventually gets enabled but some error messages are displayed along the way
  • The change in D8 core that cause the error to happen is:
    $form_state->set('langcode', $this->entityRepository->getTranslationFromContext($this->entity)->language()->getId());
    When up untill the previous version (8.5.x) the code was:
    $form_state->set('langcode', $this->entityManager->getTranslationFromContext($this->entity)->language()->getId());
albertski’s picture

Status: Active » Needs review
StatusFileSize
new1.47 KB

Attached patch fixes the issue.

redeight’s picture

Status: Needs review » Reviewed & tested by the community

#5 works wonderfully. Thank you!

stephen ollman’s picture

+1 #5 patch.

szeidler’s picture

Thanks for the patch #5. It's working fine for me in Drupal 8.6.1 and a multilingual environment.

The failing tests are unrelated to this issue here.

nathandentzau’s picture

Status: Reviewed & tested by the community » Needs work

We should depend on the interface, not the concrete class of QueryBase.

nathandentzau’s picture

StatusFileSize
new877 bytes

My apologies, I see that QueryBase is already in this module. Upon further investigation, the MailchimpCampaignForm is overriding the ContentEntityForm::__construct() and ContentEntityForm::create() methods for the entity query factory service, however it's never used in the class. I suggest we remove this all together.

nathandentzau’s picture

Priority: Major » Critical
Status: Needs work » Needs review

Updated to critical because it's throwing a fatal error on the campaigns management page.

The last submitted patch, 5: mailchimp-create_campaign_error-2999528-4.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

lluvigne’s picture

I think that proposed solution from @nathandentzau at #10 is the correct way to solve this issue. I tested locally on a fresh Drupal 8.6.1 install and all works fine.

albertski’s picture

Agree with @ nathandentzau. I updated the patch to remove the unused Use statements.

szeidler’s picture

Status: Needs review » Reviewed & tested by the community

Thank you both for simplifying the patch. It is working fine for me.

  • rjacobsen0 committed 6a3e2c4 on 8.x-1.x authored by albertski
    Issue #2999528 by albertski, nathandentzau: Create Campaign results in...
rjacobsen0’s picture

Status: Reviewed & tested by the community » Fixed

  • rjacobsen0 committed 6991f82 on 8.x-1.x
    Revert "Issue #2999528 by albertski, nathandentzau: Create Campaign...
rjacobsen0’s picture

Status: Fixed » Reviewed & tested by the community

Wrong message. Will commit again soon.

OCTOGONE.dev’s picture

thank you @ albertski & nathandentzau

patch #14 is working for me.

GeoffGlasson’s picture

I'm unfamiliar with the module's release cycle, so I was wondering when this patch is likely to be pushed out into a production release, especially given that the released module is effectively unusable due to this bug. Any update would be most appreciated. Thanks.

samuel.mortenson’s picture

Assigned: Unassigned » rjacobsen0
rjacobsen0’s picture

Committing correct patch with correct message.

rjacobsen0’s picture

Status: Reviewed & tested by the community » Fixed

  • rjacobsen0 committed 66f2f86 on 8.x-1.x authored by albertski
    Issue #2999528 by albertski, nathandentzau, rjacobsen0: Create Campaign...

Status: Fixed » Closed (fixed)

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