Description
Problem can be caused by the anonymous user having the wrong id in DB.
Full error:
The website encountered an unexpected error. Please try again later.
Error: Call to a member function getCacheMaxAge() on null in Drupal\views\Plugin\views\query\Sql->getCacheMaxAge() (line 1696 of core/modules/views/src/Plugin/views/query/Sql.php).
Drupal\views\Plugin\views\query\Sql->getCacheMaxAge() (Line: 263)
Drupal\views\Plugin\views\cache\CachePluginBase->getCacheMaxAge() (Line: 681)
Drupal\views\Plugin\views\style\StylePluginBase->renderFields() (Line: 579)
Drupal\views\Plugin\views\style\StylePluginBase->renderGrouping() (Line: 470)
Drupal\views\Plugin\views\style\StylePluginBase->render() (Line: 2169)
Drupal\views\Plugin\views\display\DisplayPluginBase->render() (Line: 1538)
Drupal\views\ViewExecutable->render() (Line: 199)
Drupal\views\Plugin\views\display\Page->execute() (Line: 1635)
Drupal\views\ViewExecutable->executeDisplay() (Line: 81)
Drupal\views\Element\View::preRenderViewElement()
call_user_func_array() (Line: 101)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 788)
Drupal\Core\Render\Renderer->doCallback() (Line: 374)
Drupal\Core\Render\Renderer->doRender() (Line: 204)
Drupal\Core\Render\Renderer->render() (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 243)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
call_user_func() (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 174)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 44)
Drupal\services\StackMiddleware\FormatSetter->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 713)
Drupal\Core\DrupalKernel->handle() (Line: 19)
Steps
-
find the UUID of the anonymous user
Consider using a backup of the db, or another instance of the site. If you don't have access to such thing consider generating a new user, copying their UUID, deleting the new user, and using that UUID for the next steps.
-
either find the original anonymous user using the UUID from a different instance of the site, or create one with the new UUID
-
set the anonymous user's UID to 0 to fix the issue