Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throwing NotFoundHttpException in form constructor causes recursion with path-based breadcrumbs on 404/403 pages #9

Closed
Hydraner opened this issue Sep 20, 2023 · 2 comments · Fixed by #19
Labels
bug Something isn't working status:fixed The issue has been resolved (usually by committing/merging code)
Milestone

Comments

@Hydraner
Copy link
Contributor

Hydraner commented Sep 20, 2023

Edit by @jensschuppe:

There is a recursion when the constructor of the RegisterForm throws a NotFoundHttpException and the resulting 404 page includes a breadcrumb; the PathBasedBreadcrumbBuilder tries to resolve the title of the event registration form and causes the constructor again to issue a NotFoundHttpException - that's where the recursion starts.

Here tThe stacktrace. The custom PathBasedBreadcrumbBuilder is not doing anything here but calling the parent PathBasedBreadcrumbBuilder from core.

The result is a recursion.

RegisterForm.php:122, Drupal\civiremote_event\Form\RegisterForm->__construct()
RegisterForm.php:180, Drupal\civiremote_event\Form\RegisterForm::create()
ClassResolver.php:28, Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition()
ControllerResolver.php:116, Drupal\Core\Controller\ControllerResolver->createController()
ControllerResolver.php:68, Drupal\Core\Controller\ControllerResolver->getControllerFromDefinition()
CustomAccessCheck.php:65, Drupal\Core\Access\CustomAccessCheck->access()
AccessManager.php:160, call_user_func_array:{/var/www/html/web/core/lib/Drupal/Core/Access/AccessManager.php:160}()
AccessManager.php:160, Drupal\Core\Access\AccessManager->performCheck()
AccessManager.php:136, Drupal\Core\Access\AccessManager->check()
AccessManager.php:113, Drupal\Core\Access\AccessManager->checkRequest()
AccessAwareRouter.php:104, Drupal\Core\Routing\AccessAwareRouter->checkAccess()
AccessAwareRouter.php:89, Drupal\Core\Routing\AccessAwareRouter->matchRequest()
PathBasedBreadcrumbBuilder.php:225, Drupal\system\PathBasedBreadcrumbBuilder->getRequestForPath()
PathBasedBreadcrumbBuilder.php:171, Drupal\system\PathBasedBreadcrumbBuilder->build()
PathBasedBreadcrumbBuilder.php:21, Drupal\bwp_base\Breadcrumb\PathBasedBreadcrumbBuilder->build()
BreadcrumbManager.php:83, Drupal\Core\Breadcrumb\BreadcrumbManager->build()
…
@jensschuppe jensschuppe changed the title Issue with exception on RegisterForm Access callback in combination with PathBasedBreadcrumbBuilder Throwing NotFoundHttpException in form constructor causes recursion with path-based breadcrumbs on 404/403 pages Sep 20, 2023
@systopia systopia deleted a comment from Hydraner Sep 20, 2023
@systopia systopia deleted a comment from Hydraner Sep 20, 2023
@jensschuppe
Copy link
Collaborator

This will need refactoring of the form constructor, moving all initialization stuff into a separate method, so that access checks will be done by the defined access callback and do not rely on exceptions, that do not seem to be caught reliably.

Current workaround is to not include breadcrumbs in 404 pages.

@jensschuppe
Copy link
Collaborator

Fixed via #19.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status:fixed The issue has been resolved (usually by committing/merging code)
Projects
None yet
3 participants