Problem/Motivation
I go to a taxonomy term page that used domain entity :
I get the following fatal error :
The website encountered an unexpected error. Please try again later.
Error: Call to a member function id() on null in domain_entity_entity_access() (line 496 of modules/contrib/domain_entity/domain_entity.module).
domain_entity_entity_access(Object, 'view', Object)
call_user_func_array('domain_entity_entity_access', Array) (Line: 403)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_access', Array) (Line: 96)
Drupal\Core\Entity\EntityAccessControlHandler->access(Object, 'view', Object, 1) (Line: 709)
Drupal\Core\Entity\ContentEntityBase->access('view', Object, 1) (Line: 65)
Drupal\Core\Entity\EntityAccessCheck->access(Object, Object, Object)
call_user_func_array(Array, Array) (Line: 159)
Drupal\Core\Access\AccessManager->performCheck('access_check.entity', Object) (Line: 135)
Drupal\Core\Access\AccessManager->check(Object, Object, Object, 1) (Line: 112)
Drupal\Core\Access\AccessManager->checkRequest(Object, Object, 1) (Line: 109)
Drupal\Core\Routing\AccessAwareRouter->checkAccess(Object) (Line: 94)
Drupal\Core\Routing\AccessAwareRouter->matchRequest(Object) (Line: 150)
Drupal\Core\Routing\AccessAwareRouter->match('/taxonomy/term/139') (Line: 138)
Drupal\user\Plugin\LanguageNegotiation\LanguageNegotiationUserAdmin->isAdminPath(Object) (Line: 104)
Drupal\user\Plugin\LanguageNegotiation\LanguageNegotiationUserAdmin->getLangcode(Object) (Line: 186)
Drupal\language\LanguageNegotiator->negotiateLanguage('language_interface', 'language-user-admin') (Line: 131)
Drupal\language\LanguageNegotiator->initializeType('language_interface') (Line: 218)
Drupal\language\ConfigurableLanguageManager->getCurrentLanguage() (Line: 220)
Drupal\domain_config\DomainConfigOverrider->initiateContext() (Line: 108)
Drupal\domain_config\DomainConfigOverrider->loadOverrides(Array) (Line: 209)
Drupal\Core\Config\ConfigFactory->loadOverrides(Array) (Line: 169)
Drupal\Core\Config\ConfigFactory->doLoadMultiple(Array, 1) (Line: 68)
Drupal\domain_config_ui\Config\ConfigFactory->doLoadMultiple(Array, 1) (Line: 104)
Drupal\Core\Config\ConfigFactory->doGet('system.date', 1) (Line: 109)
Drupal\domain_config_ui\Config\ConfigFactory->doGet('system.date') (Line: 89)
Drupal\Core\Config\ConfigFactory->get('system.date') (Line: 90)
Drupal\system\TimeZoneResolver->getTimeZone() (Line: 53)
Drupal\system\TimeZoneResolver->setDefaultTimeZone(Object, 'account.set', Object)
call_user_func(Array, Object, 'account.set', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'account.set') (Line: 65)
Drupal\Core\Session\AccountProxy->setAccount(Object) (Line: 79)
Drupal\Core\EventSubscriber\AuthenticationSubscriber->onKernelRequestAuthenticate(Object, 'kernel.request', Object)
call_user_func(Array, Object, 'kernel.request', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.request') (Line: 134)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
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: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->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: 706)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
- enable domain, domain_entity, I used domain for a vocabulary taxonony term
- enable two languages, in my case french and english, priority to french.
- use "user admin language" option in language detection
- go to a taxonomy page with an account like admin and choice language for admin
- get the fatal error.
Proposed resolution
In modules/contrib/domain_entity/domain_entity.module:496
We call domain_entity_get_domain , it invokes \Drupal::service('domain.negotiator')->getActiveDomain() that return null for current domain.
Just change
return \Drupal::service('domain.negotiator')->getActiveDomain() to return \Drupal::service('domain.negotiator')->getActiveDomain(TRUE); fixed the problem for me .
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | current-domain-null-3201343-6.patch | 714 bytes | willeaton |
| #4 | fix-3201343.patch | 470 bytes | tichris59 |
Comments
Comment #2
tichris59 commentedComment #3
tichris59 commentedComment #4
tichris59 commentedComment #5
willeaton commentedThis patch seems to have reached the beta version (8.x-1.0-beta6) yet it creates the opposite issue for me.
In /store/2/duplicate when trying to duplicate a store,
... this returns NULL for me causing the next line:
to give a fatal error because you can't get id() on NULL.
Comment #6
willeaton commentedHere's a patch with a similar fix to that being implemented in domain_menus:
https://www.drupal.org/project/domain_menus/issues/3262997
Note its a temporary fix until the main "domain" module resolves this issue.
Comment #8
delta commentedComment #9
delta commentedreleased in https://www.drupal.org/project/domain_entity/releases/8.x-1.0-beta7