- Issue created by @daniel.delaiglesia
- Status changed to Postponed: needs info
2 months ago 12:39am 22 January 2025 - 🇮🇳India gaurav.kapoor
@daniel.delaiglesia Do we need this change? Isn't default behaviour on viewing a unpublished term is 404 page not found?
- Status changed to Active
11 days ago 11:43am 27 March 2025 - 🇪🇸Spain eduardo morales alberti Spain, 🇪🇺
We are testing it, and on Drupal 10.4 we are getting 403 and on Drupal 11 it returns the default language.
- Merge request !4Issue #3403079 by daniel.delaiglesia, eduardo morales alberti: Support for taxonomy terms → (Open) created by eduardo morales alberti
- 🇪🇸Spain eduardo morales alberti Spain, 🇪🇺
We also avoid fallback language when the translation does not exists.
// Check if content is on the current language. // Access only published content. if (($entity->isTranslatable() && (!$entity->hasTranslation($current_language) || !($entity->language()->getId() === $current_language)) ) || (!$this->currentUser->hasPermission('view any unpublished content') && !$entity->isPublished()) ) { $cacheability = CacheableMetadata::createFromObject($entity)->addCacheContexts(['route', 'user.permissions']); $reason = 'Content not found or not accessible.'; throw new CacheableNotFoundHttpException($cacheability, $reason); }
- 🇪🇸Spain eduardo morales alberti Spain, 🇪🇺
The access denied comes from:
\Symfony\Component\HttpKernel\EventListener\RouterListener
\Symfony\Component\HttpKernel\EventListener\RouterListener::getSubscribedEvents
public static function getSubscribedEvents(): array { return [ KernelEvents::REQUEST => [['onKernelRequest', 32]], KernelEvents::FINISH_REQUEST => [['onKernelFinishRequest', 0]], KernelEvents::EXCEPTION => ['onKernelException', -64], ]; }
\Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest
// matching a request is more powerful than matching a URL path + context, so try that first if ($this->matcher instanceof RequestMatcherInterface) { $parameters = $this->matcher->matchRequest($request);
\Drupal\Core\Routing\AccessAwareRouter::matchRequest
public function matchRequest(Request $request): array { $parameters = $this->router->matchRequest($request); $request->attributes->add($parameters); $this->checkAccess($request);
\Drupal\Core\Routing\AccessAwareRouter::checkAccess
if (!$access_result->isAllowed()) { if ($access_result instanceof CacheableDependencyInterface && $request->isMethodCacheable()) { throw new CacheableAccessDeniedHttpException($access_result, $access_result instanceof AccessResultReasonInterface ? $access_result->getReason() : ''); }
So we subscribe before it to give the 404.
/** * {@inheritdoc} */ public static function getSubscribedEvents() { return [ // Launch method before RouterListener. // @see \Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest(). KernelEvents::REQUEST => ['onKernelRequest', 33], ]; }