0

I cloned a version of a Drupal 8.9.20 site to a local installation (MAMP PRO). That seemed to word, but when I call the site I get an error:

The website encountered an unexpected error. Please try again later.

With verbose error mode I get further:

Error: Call to a member function id() on bool in Drupal\Core\Entity\EntityStorageBase->setStaticCache() (line 188 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).
Drupal\Core\Entity\EntityStorageBase->setStaticCache(Array) (Line: 311)
Drupal\Core\Entity\EntityStorageBase->loadMultiple(Array) (Line: 188)
Drupal\Core\Entity\EntityRepository->getCanonicalMultiple('node', Array, Array) (Line: 180)
Drupal\Core\Entity\EntityRepository->getCanonical('node', '236', Array) (Line: 149)
Drupal\Core\ParamConverter\EntityConverter->convert('236', Array, 'node', Array) (Line: 100)
Drupal\Core\ParamConverter\ParamConverterManager->convert(Array) (Line: 89)
Drupal\Core\Access\AccessManager->checkNamedRoute('entity.node.canonical', Array, Object, 1) (Line: 212)
Drupal\Core\Menu\DefaultMenuLinkTreeManipulators->menuLinkCheckAccess(Object) (Line: 92)
Drupal\Core\Menu\DefaultMenuLinkTreeManipulators->checkAccess(Array) (Line: 96)
Drupal\Core\Menu\DefaultMenuLinkTreeManipulators->checkAccess(Array) (Line: 96)
Drupal\Core\Menu\DefaultMenuLinkTreeManipulators->checkAccess(Array)
call_user_func(Array, Array) (Line: 148)
Drupal\Core\Menu\MenuLinkTree->transform(Array, Array) (Line: 56)
Drupal\pg_helper\BreadcrumbBuilder->build(Object) (Line: 47)
Drupal\pg_fe_users\Theme\ThemeswitcherNegotiator::is_internal() (Line: 23)
Drupal\pg_fe_users\Theme\ThemeswitcherNegotiator->applies(Object) (Line: 67)
Drupal\Core\Theme\ThemeNegotiator->determineActiveTheme(Object) (Line: 405)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 43)
Drupal\Core\Cache\Context\ThemeCacheContext->getContext(NULL) (Line: 118)
Drupal\Core\Cache\Context\CacheContextsManager->convertTokensToKeys(Array) (Line: 307)
Drupal\Core\Render\RenderCache->createCacheID(Array) (Line: 66)
Drupal\Core\Render\RenderCache->get(Array) (Line: 109)
Drupal\Core\Render\PlaceholderingRenderCache->get(Array) (Line: 77)
Drupal\Core\Render\RenderCache->get(Array) (Line: 109)
Drupal\Core\Render\PlaceholderingRenderCache->get(Array) (Line: 137)
Drupal\dynamic_page_cache\EventSubscriber\DynamicPageCacheSubscriber->onRequest(Object, 'kernel.request', Object)
call_user_func(Array, Object, 'kernel.request', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.request', Object) (Line: 127)
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: 191)
Drupal\page_cache\StackMiddleware\PageCache->fetch(Object, 1, 1) (Line: 128)
Drupal\page_cache\StackMiddleware\PageCache->lookup(Object, 1, 1) (Line: 82)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 70)
Drupal\pg_fe_users\StackMiddleware\PgPageCache->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: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

What could be the reason? Any hints how to resolve this?

For your advice many thanks in advance!

Solution:

The advice from @4k4 solved the problem:

Rebuilding the cache by http://www.example.com/core/rebuild.php removed the error message.

9
  • How did you clone the files/db? Feb 10, 2022 at 7:45
  • The files via ssh and zip. The dd via mysqldump and then imported into phpMyAdmin.
    – berlindave
    Feb 10, 2022 at 7:48
  • What the error dump can tell is that the error occurs in a cache hit where the dynamic page cache is trying to replace placeholders which involves a custom theme negotiator, which, quite unusually, causes this error while trying to find out if it applies. No matter how you found this error this might be interesting to the authors of the custom code.
    – 4uk4
    Feb 10, 2022 at 8:17
  • @4k4, thank you for this hint. Is there an easy solution to remove this caching behaviour?
    – berlindave
    Feb 10, 2022 at 8:31
  • You could simply try to clear the cache and hope the error is not coming back. Or use the site as it is now to debug how a bool ends up in the variables instead of an entity.
    – 4uk4
    Feb 10, 2022 at 8:48

1 Answer 1

2

Rebuilding the cache by http://www.example.com/core/rebuild.php removed the error message.

See https://www.drupal.org/docs/user_guide/en/prevent-cache-clear.html#s-using-the-rebuild-script

This is a quick fix to remove the cached page which prevents the site from loading. To find what is causing the error you could use the site in the state it is before the cache clear and xdebug the variables to find the boolean which is wrongly put in place of an entity.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.