Score:0

Error on local clone (MAMP)

ua flag

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.

cn flag
How did you clone the files/db?
ua flag
The files via ssh and zip. The dd via mysqldump and then imported into phpMyAdmin.
4uk4 avatar
cn flag
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.
ua flag
@4k4, thank you for this hint. Is there an easy solution to remove this caching behaviour?
4uk4 avatar
cn flag
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.
ua flag
@4k4 Unfortunately the site doesn't show up. Just this error. And unfortunately I'm a complete Drupal newbie. I'm normally developing WordPress Themes. Is there a way to clear the cache manually?
4uk4 avatar
cn flag
Use drush cache:rebuild or the rebuild script. See https://www.drupal.org/docs/user_guide/en/prevent-cache-clear.html#s-using-the-rebuild-script
cn flag
Also, generally speaking, MAMP and Drupal don't play together so nicely. If you're going to be using Drupal a lot, it's much better to use one of the docker-based tools like ddev or lando (both open source and free of charge).
ua flag
@4k4 Thank you very much! http://www.example.com/core/rebuild.php did the trick!
Score:2
cn flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.