This problem is critial, the module breaks important Drupal behaviour!

Problem:

Non existing routes lead to a ResourceNotFoundException instead of a clean 404 when this module is installed .

Auf der Website ist ein unvorhergesehener Fehler aufgetreten. Bitte versuchen Sie es später nochmal.Symfony\Component\Routing\Exception\ResourceNotFoundException: No routes found for "/nonExistingExamplePage". in Drupal\Core\Routing\Router->matchRequest() (line 125 of core/lib/Drupal/Core/Routing/Router.php).

Drupal\administration_language_negotiation\Plugin\AdministrationLanguageNegotiationCondition\AdminRoutes->isAdminRoute() (Line: 113)
Drupal\administration_language_negotiation\Plugin\AdministrationLanguageNegotiationCondition\AdminRoutes->evaluate() (Line: 80)
Drupal\administration_language_negotiation\AdministrationLanguageNegotiationConditionManager->execute(Object) (Line: 86)
Drupal\administration_language_negotiation\Plugin\LanguageNegotiation\LanguageNegotiationAdministrationLanguage->getLangcode(Object) (Line: 186)
Drupal\language\LanguageNegotiator->negotiateLanguage('language_interface', 'administration-language-negotiation') (Line: 131)
Drupal\language\LanguageNegotiator->initializeType('language_interface') (Line: 218)
Drupal\language\ConfigurableLanguageManager->getCurrentLanguage() (Line: 93)
Drupal\language\EventSubscriber\LanguageRequestSubscriber->setLanguageOverrides() (Line: 75)
Drupal\language\EventSubscriber\LanguageRequestSubscriber->onKernelRequestLanguage(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: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->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: 666)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Reproduction:

  1. Install this module
  2. Activate Administration language (/admin/config/regional/language/detection)
  3. Select URL as further handler (/admin/config/regional/language/detection) - I used /de and /en in my test
  4. Enable "Admin Routes" (/admin/config/regional/language/detection/administration_language)
  5. Call any non existing URL... e.g. /thispagedoesntexist
  6. Boom!

Comments

Anybody created an issue. See original summary.

anybody’s picture

Title: Admin routes check breaks Route handling! ResourceNotFoundException » Admin routes check breaks Route handling! ResourceNotFoundException instead of 404
anybody’s picture

Issue summary: View changes
richardcanoe’s picture

StatusFileSize
new1.11 KB

This should work :-)

richardcanoe’s picture

Status: Active » Needs review
richardcanoe’s picture

StatusFileSize
new1.17 KB
anybody’s picture

Status: Needs review » Needs work

Nope!

Auf der Website ist ein unvorhergesehener Fehler aufgetreten. Bitte versuchen Sie es später nochmal.Symfony\Component\Routing\Exception\ResourceNotFoundException: No routes found for "/test". in Drupal\Core\Routing\Router->matchRequest() (line 125 of core/lib/Drupal/Core/Routing/Router.php).

Drupal\administration_language_negotiation\Plugin\AdministrationLanguageNegotiationCondition\AdminRoutes->isAdminRoute() (Line: 113)
Drupal\administration_language_negotiation\Plugin\AdministrationLanguageNegotiationCondition\AdminRoutes->evaluate() (Line: 80)
Drupal\administration_language_negotiation\AdministrationLanguageNegotiationConditionManager->execute(Object) (Line: 86)
Drupal\administration_language_negotiation\Plugin\LanguageNegotiation\LanguageNegotiationAdministrationLanguage->getLangcode(Object) (Line: 186)
Drupal\language\LanguageNegotiator->negotiateLanguage('language_interface', 'administration-language-negotiation') (Line: 131)
Drupal\language\LanguageNegotiator->initializeType('language_interface') (Line: 218)
Drupal\language\ConfigurableLanguageManager->getCurrentLanguage() (Line: 93)
Drupal\language\EventSubscriber\LanguageRequestSubscriber->setLanguageOverrides() (Line: 75)
Drupal\language\EventSubscriber\LanguageRequestSubscriber->onKernelRequestLanguage(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: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->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: 666)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
richardcanoe’s picture

StatusFileSize
new2.78 KB

Missing use case added.

richardcanoe’s picture

Status: Needs work » Needs review
beram’s picture

StatusFileSize
new6.19 KB
new5.01 KB

Hi,

The patch from comment #8 seems to work.

Nevertheless I modified it in order to:

  • use the service router.admin_context provided by Core which contains a isAdminRoute() method rather than doing what it already does. I also added a comment to explain why just using this method is not enough.
  • clean a little bit:
    • the services config.factory and language_manager were instantiated but never used
    • the comment for the AdminRoutes constructor was wrong. It does not Constructs a RequestPath condition plugin. and parameters were missing
    • the new line for catch was breaking the phpcs configuration setup on this project. (I'd like one day to see this project adopting Drupal coding standard)

IMHO we also need to setup some tests to avoid regression in the future.

You'll also find the interdiff.

Regards,

  • Pol committed 3a12548 on 8.x-1.x authored by beram
    Issue #2983798 by richardcanoe, beram: Admin routes check breaks Route...
pol’s picture

Status: Needs review » Fixed

Very nice patch, thanks !!!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.