After updating to beta10 and Drupal 8.7.1

I got the following error:

The website encountered an unexpected error. Please try again later.
Error: Call to a member function getThirdPartySetting() on null in contact_storage_form_contact_message_form_alter() (line 189 of modules/contrib/contact_storage/contact_storage.module).
contact_storage_form_contact_message_form_alter(Array, Object, 'contact_message_a_survey_form') (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'contact_message_a_survey_form') (Line: 835)
Drupal\Core\Form\FormBuilder->prepareForm('contact_message_a_survey_form', Array, Object) (Line: 277)
Drupal\Core\Form\FormBuilder->buildForm('contact_message_a_survey_form', Object) (Line: 61)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object) (Line: 120)
Drupal\contact_formatter\Plugin\Field\FieldFormatter\ContactFieldFormatter->viewElements(Object, 'en') (Line: 80)
Drupal\Core\Field\FormatterBase->view(Object, 'en') (Line: 263)
Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array) (Line: 343)
Drupal\Core\Entity\EntityViewBuilder->buildComponents(Array, Array, Array, 'default') (Line: 285)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 18)
Drupal\paragraphs\ParagraphViewBuilder->buildMultiple(Array) (Line: 242)
Drupal\Core\Entity\EntityViewBuilder->build(Array)
call_user_func(Array, Array) (Line: 378)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 501)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 90)
__TwigTemplate_30cc57746888ffd825622bd76daa0185a5dd1999b209d196b1ddd946dd827cbf->doDisplay(Array, Array) (Line: 443)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 414)
Twig\Template->display(Array) (Line: 422)
Twig\Template->render(Array) (Line: 64)

The weird is that there is no such contact_form: 'contact_message_a_survey_form'.

CommentFileSizeAuthor
#2 3055176-2.patch2.94 KBedurenye

Comments

edurenye created an issue. See original summary.

edurenye’s picture

Status: Active » Needs review
StatusFileSize
new2.94 KB

Quick fix, just skip code if no such contact_form.

berdir’s picture

Hm, that might be broken content/data. trying to create a contact message for a non-existing form is like trying to trying to view/edit a node of a non-existing type, that shouldn't be possible.

Not sure we should really care about that.

mrdalesmith’s picture

I am also getting this error in 8.6.17:

The website encountered an unexpected error. Please try again later.
Error: Call to a member function getThirdPartySetting() on null in contact_storage_form_contact_message_form_alter() (line 189 of modules/contrib/contact_storage/contact_storage.module).
contact_storage_form_contact_message_form_alter(Array, Object, 'contact_message_personal_form') (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'contact_message_personal_form') (Line: 834)
Drupal\Core\Form\FormBuilder->prepareForm('contact_message_personal_form', Array, Object) (Line: 276)
Drupal\Core\Form\FormBuilder->buildForm('contact_message_personal_form', Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object) (Line: 117)
Drupal\contact\Controller\ContactController->contactPersonalPage(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

This is caused by the core Drupal\contact\Access access check: our site uses a sitewide contact form with contact storage, but no users have personal contact forms enabled. However - because the administrator role inherits all permissions - administrators still see a tab for a non-existent contact form. If you click it, you generate the error.

The core Access seems to deliberately check for the permission (with a comment "User administrators should always have access to personal contact forms.") BEFORE it checks if the contact page is enabled. I think then that contact storage is going to have to be able to handle a contact form that doesn't exist being visited without causing a fatal error.

mrdalesmith’s picture

Can confirm the supplied patch fixes the issue, although it may not be ideal as its means admins see a contact form with no additional settings from the contact_storage module.

berdir’s picture

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

If I understand it correctly then it would make more sense to fix this in core with #3098767: Administrators can access contact forms that don't exist ?

mrdalesmith’s picture

Depends what the reason for always giving admins access to disabled contact forms is: as it's the current core behaviour they may be a good reason, in which case Contact Storage should work with it and not throw an error.

This ticket probably needs to be in requires feedback until there's an answer on the linked ticket.