Attempting to edit a content type throws a PHP Call to undefined method error

Created on 29 March 2023, about 1 year ago
Updated 18 April 2023, about 1 year ago

Problem/Motivation

Version 2.2.14 throws a PHP error when DANSE Content is enabled and you attempt to edit a content type (irrespective of whether you have changed any DANSE settings for that content type).

Error: Call to undefined method Drupal\Core\Cache\DatabaseBackend::invalidateTags() in Drupal\danse_content\Plugin\Danse\Content->submitContentTypeSettingsForm() (line 575 of /public_html/modules/contrib/danse/modules/content/src/Plugin/Danse/Content.php)
#0 [internal function]: Drupal\danse_content\Plugin\Danse\Content->submitContentTypeSettingsForm(Array, Object(Drupal\Core\Form\FormState))
#1 /public_html/core/lib/Drupal/Core/Form/FormSubmitter.php(114): call_user_func_array(Array, Array)
#2 /public_html/core/lib/Drupal/Core/Form/FormSubmitter.php(52): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState))
#3 /public_html/core/lib/Drupal/Core/Form/FormBuilder.php(595): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState))
#4 /public_html/core/lib/Drupal/Core/Form/FormBuilder.php(323): Drupal\Core\Form\FormBuilder->processForm('node_type_edit_...', Array, Object(Drupal\Core\Form\FormState))
#5 /public_html/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\node\NodeTypeForm), Object(Drupal\Core\Form\FormState))
#6 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#7 /public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#8 /public_html/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#9 /public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#10 /public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#11 /vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#12 /vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#13 /public_html/modules/contrib/redirect_after_login/src/RedirectMiddleware.php(46): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /public_html/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Drupal\redirect_after_login\RedirectMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /public_html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /public_html/modules/contrib/cleantalk/src/EventSubscriber/BootSubscriber.php(187): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /public_html/core/modules/ban/src/BanMiddleware.php(50): Drupal\cleantalk\EventSubscriber\BootSubscriber->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /public_html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /public_html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /public_html/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /public_html/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#23 {main}

Database update and cache clear was run after upgrading the module. I have also cleared the cache after first encountering the issue.

Drupal: 9.5.7
DANSE: 2.2.14
PHP: 8.1.17

Steps to reproduce

1. Enable DANSE and DANSE Content.
2. Navigate to the edit page of any content type.
3. Save the page (with or without making any changes).

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

2.2

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom Janner

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Janner
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Hmm, looks like not all cache backends implement invalidateTags.

    What we're doing is to cache all the heavy lifting about entity types and bundles and what subscriptions they support. But we need to invalidate those caches, when any content type setting gets changed. That's why we call

    $this->cacheBackend->invalidateTags(['danse.cache:' . $this->pluginId]);
    

    So, I wonder what should be done instead, any suggestions much appreciated.

  • πŸ‡ΊπŸ‡ΈUnited States rex.barkdoll

    I'm also getting this when I try to update a content type or comment type. It even happens when I'm not making any DANSE-related changes, which is frustrating.

    The good news is that even though the error occurs, changes do seem to be applied when you reload the page (by going to the URL bar and hitting return to force the page to that URL).

    Unfortunately, I don't know enough about Drupal Caching to understand why the error is occurring or how to fix it.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    I'm reaching out on Slack, maybe somebody can help us there.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    In the meantime, I've disabled the cache invalidation which causes the exception. That means, you won't see this error anymore. The downside is that changed DANSE settings will not be reflected for users until you flush your cache once.

  • Assigned to jurgenhaas
  • Status changed to Needs work about 1 year ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen
  • Status changed to Needs review about 1 year ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Got some help on Slack. There is a cache tag invalidator service in core, that allows us to do all that regardless of the used cache backend. I've implemented that in the dev release. Please give that a try.

  • πŸ‡¬πŸ‡§United Kingdom Janner

    After updating to the latest dev release, the content type edit page no longer throws the PHP error upon saving.

    However, after allowing subscription for content type (in this case it was for the publish and comment events), navigating to an existing node of that content type now throws the following PHP error:


    LogicException: The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution. in Drupal\Core\Database\Connection->__sleep() (line 2042 of /public_html/core/lib/Drupal/Core/Database/Connection.php).

    Since updating I have run drush updated and cleared the cache several times. The error persists.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    The second error sounds like this one: πŸ› LogicException: The database connection is not serializable. Fixed

    Can you confirm, that you see the same stack trace there?

  • πŸ‡¬πŸ‡§United Kingdom Janner

    It is indeed the same.

    I had not encountered this issue prior to the latest dev release.

    However, I've only been performing some very limited testing of this module to date. Consequently, it may have been present or present in different places, but my testing hasn't triggered it before now.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    @Janner I think we should be able to set this one to RTBC, can't we? And with regard to the other error, please have a look at the other issue and if that's RTBC'd as well, we can publish another release.

  • Issue was unassigned.
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen
  • Status changed to RTBC about 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom Janner
  • Status changed to Fixed about 1 year ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Thanks

  • πŸ‡ΊπŸ‡ΈUnited States rex.barkdoll

    Also confirming that the error is gone on my end. Thank you for all your hard work on this. :)

  • Status changed to Fixed about 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024