- Issue created by @keinstein
- last update
over 1 year ago Custom Commands Failed The error is โ The 'entity:user' context is required and not presentโ.
https://www.drupal.org/forum/support/post-installation/2022-03-12/how-to... โ
https://www.drupal.org/project/migration_tools/issues/3353844 ๐ฌ 'entity:user' context is required and not present Closed: cannot reproduce
- ๐ฉ๐ชGermany keinstein
@cilefen What do you mean with the links?
I don't see why change in
templates/layout/page.html.twig
or playing around withscss
andcss
files should trigger such a bug.A framework that is so sensitive to changes is buggy in my opinion. Or in other words: If the theme is buggy the framework should help the themers to track down the error and not blur it.
Btw.: How do the links relate to https://www.drupal.org/node/2934192 โ and the comment in the following source code?
// @todo At the moment we do not need the current user context, which is // triggering some test failures. We can remove these lines once // https://www.drupal.org/node/2934192 is fixed.
- ๐บ๐ธUnited States webdrips
The patch worked for me.
The problem occurred during a migration (I believe it was during migrate-import --all).
I couldn't view the site as an anonymous user.
- Status changed to RTBC
over 1 year ago 7:22am 6 June 2023 - ๐บ๐ฆUkraine rollins
patch resolved the bug, now an anonymous user can see the website
I am using Drupal Core 9.5.9 - Status changed to Needs work
over 1 year ago 10:17am 6 June 2023 The patch did not pass code quality tests. Also it lacks regression test coverage.
- Status changed to Needs review
over 1 year ago 12:12pm 6 June 2023 - last update
over 1 year ago 30,335 pass - ๐ฎ๐ณIndia karishmaamin
Tried to fix custom code error with the patch
- Status changed to Needs work
over 1 year ago 1:34pm 6 June 2023 - ๐บ๐ธUnited States smustgrave
Previously tagged for tests that still need to happen.
Also should target the 11.x branch as that's the current development branch. Changes can be backported later.
- ๐ฆ๐บAustralia dpi Perth, Australia
Is this the same issue as ๐ User context missing when using toUrl in some circumstances Needs work ? likey caused by a missing anonymous user row from a bad database dump
- ๐ฌ๐งUnited Kingdom joachim
+++ b/core/lib/Drupal/Core/ParamConverter/EntityConverter.php @@ -146,8 +147,12 @@ public function convert($value, $definition, $name, array $defaults) { + catch (ContextException $e) { + }
Silently catching an exception doesn't seem like a good fix to me.
At the very least this requires a comment to explain a) why this might happen and b) why it's ok to silently ignore it.
- ๐ซ๐ทFrance Syone
Hello, I have the same issue after updating the database with the update.php script. Has anyone find out how to fix this?
- ๐ซ๐ทFrance Syone
I finally find out what happened, this is what @dpi described.
I've made a database dump and then reload it in my local MySQL database.
The insert query try to create a user with a uid = 0 (the anonymous user) but in MySQL when the mode NO_AUTO_VALUE_ON_ZERO is not enable, it will use the auto increment sequence instead of inserting 0 as uid. - Status changed to Closed: duplicate
over 1 year ago 8:25am 19 July 2023 - ๐ฆ๐บAustralia dpi Perth, Australia
Closing this as duplicate ๐ User context missing when using toUrl in some circumstances Needs work . I also see the patch in both issues are very similar.
Reopen if the differences can be described.
- ๐ง๐ชBelgium herved
I have now stumbled on this for 2 projects in behat tests.
FWIW in my case it's not the missing anonymous user issue (it's there) ๐ The 'entity:user' context is required and not present Closed: duplicate
Here is my stacktrace:Context.php:72, Drupal\Core\Plugin\Context\Context->getContextValue() EntityConverter.php:149, Drupal\Core\ParamConverter\EntityConverter->convert() ParamConverterManager.php:100, Drupal\Core\ParamConverter\ParamConverterManager->convert() ParamConversionEnhancer.php:45, Drupal\Core\Routing\Enhancer\ParamConversionEnhancer->enhance() Router.php:270, Drupal\Core\Routing\Router->applyRouteEnhancers() Router.php:150, Drupal\Core\Routing\Router->matchRequest() AccessAwareRouter.php:90, Drupal\Core\Routing\AccessAwareRouter->matchRequest() AccessAwareRouter.php:144, Drupal\Core\Routing\AccessAwareRouter->match() LanguageNegotiationUserAdmin.php:138, Drupal\user\Plugin\LanguageNegotiation\LanguageNegotiationUserAdmin->isAdminPath() LanguageNegotiationUserAdmin.php:104, Drupal\user\Plugin\LanguageNegotiation\LanguageNegotiationUserAdmin->getLangcode() LanguageNegotiator.php:197, Drupal\language\LanguageNegotiator->negotiateLanguage() LanguageNegotiator.php:137, Drupal\language\LanguageNegotiator->initializeType() ConfigurableLanguageManager.php:218, Drupal\language\ConfigurableLanguageManager->getCurrentLanguage() LanguageRequestSubscriber.php:92, Drupal\language\EventSubscriber\LanguageRequestSubscriber->setLanguageOverrides() LanguageRequestSubscriber.php:74, Drupal\language\EventSubscriber\LanguageRequestSubscriber->onKernelRequestLanguage() ContainerAwareEventDispatcher.php:111, call_user_func:{/home/herve/Documents/commission/ecdc/ecdc-monorepo/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php:111}() ContainerAwareEventDispatcher.php:111, Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() HttpKernel.php:142, Symfony\Component\HttpKernel\HttpKernel->handleRaw() HttpKernel.php:74, Symfony\Component\HttpKernel\HttpKernel->handle() Session.php:58, Drupal\Core\StackMiddleware\Session->handle() KernelPreHandle.php:48, Drupal\Core\StackMiddleware\KernelPreHandle->handle() ReverseProxyMiddleware.php:48, Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() NegotiationMiddleware.php:51, Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() StackedHttpKernel.php:51, Drupal\Core\StackMiddleware\StackedHttpKernel->handle() DrupalKernel.php:704, Drupal\Core\DrupalKernel->handle() index.php:19, {main}()
This issue seems to happen somewhat randomly for me.
After some investigation, this is happening exclusively on image styles routes.
I believe the random factor is partially due to the fact that I use selenium, and the browser caches images (so disabling selenium's browser cache helps), but also a race condition as follows: behat ends the scenario, deletes the user, and at the same time, the homepage gets refreshed and lazy loads the images, creating new requests.
Most probably the user still exists at the beginning of these image styles requests, but behat (still running in the background) deletes the user and when the image style requests arrives in\Drupal\user\ContextProvider\CurrentUserContext::getRuntimeContexts
and attempts to load the user, it returns NULL (this I confirmed), causing in turnThe 'entity:user' context is required and not present
exception to be thrown from\Drupal\Core\Plugin\Context\Context::getContextValue
I will see if ๐ User context missing when using toUrl in some circumstances Needs work helps solving the issue.
PS: I know this issue is closed but perhaps this info could be useful to someone else, who knows.