Page Manager loses defaults of overidden route

Created on 7 September 2022, almost 2 years ago
Updated 25 June 2024, 4 days ago

Problem/Motivation

I'm currently using page_manager to override Webform Node's node-associated submission page (/node/{node}/webform/submission/{webform_submission}) just like I would override any other entity's canonical page. The original route definition for /node/{node}/webform/submission/{webform_submission} is:

entity.node.webform_submission.canonical:
  path: '/node/{node}/webform/submission/{webform_submission}'
  defaults:
    _controller: '\Drupal\webform\Controller\WebformSubmissionViewController::view'
    _title_callback: '\Drupal\webform\Controller\WebformSubmissionViewController::title'
    view_mode: 'html'
    operation: webform_submission_view
    entity_access: 'webform_submission.view'
  options:
    _admin_route: TRUE
    parameters:
      node:
        type: 'entity:node'
  requirements:
    _custom_access: '\Drupal\webform_node\Access\WebformNodeAccess::checkWebformSubmissionAccess'

I've properly filled in the types for both {node} and {webform_submission} parameters in the route. However, when I view a submission using a page_manager page, I get this error:

RuntimeException: Callable "Drupal\webform_node\Access\WebformNodeAccess::checkWebformSubmissionAccess" requires a value for the "$operation" argument. in Drupal\Component\Utility\ArgumentsResolver->handleUnresolvedArgument() (line 143 of core/lib/Drupal/Component/Utility/ArgumentsResolver.php).

Drupal\Component\Utility\ArgumentsResolver->getArgument(Object) (Line: 54)
Drupal\Component\Utility\ArgumentsResolver->getArguments(Array) (Line: 73)
Drupal\Core\Access\CustomAccessCheck->access(Object, Object, Object)
call_user_func_array(Array, Array) (Line: 160)
Drupal\Core\Access\AccessManager->performCheck('access_check.custom', Object) (Line: 136)
Drupal\Core\Access\AccessManager->check(Object, Object, Object, 1) (Line: 113)
Drupal\Core\Access\AccessManager->checkRequest(Object, Object, 1) (Line: 110)
Drupal\Core\Routing\AccessAwareRouter->checkAccess(Object) (Line: 95)
Drupal\Core\Routing\AccessAwareRouter->matchRequest(Object) (Line: 112)
Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest(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: 46)
Drupal\redirect_after_login\RedirectMiddleware->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
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: 265)
Drupal\shield\ShieldMiddleware->bypass(Object, 1, 1) (Line: 132)
Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 709)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Upon closer inspection, it appears that WebformNodeAccess::checkWebformSubmissionAccess() is being called to check the access of the page, and it's expecting $operation and $entity_access from the route parameters, which normally appears to resolve to the values in the defaults of the original route. But when page_manager is overriding the route, the $route object does not contain the original route's default values.

I am not sure if this is intended or a bug. I saw two other issues that were related to route defaults which leads me to believe this is a bug:
- https://www.drupal.org/project/page_manager/issues/2549997 β†’
- https://www.drupal.org/project/page_manager/issues/2820218 πŸ› Page manager does not respect existing route defaults for title callbacks Needs work

I also have the patch from https://www.drupal.org/project/page_manager/issues/2665328 πŸ› Fix Variants take entity label, not the variant title Needs work applied

Steps to reproduce

1. Enable page_manager and webform_node.
2. Create a webform with some text fields.
3. Create a node type with a webform field. Ensure the webform field is rendered on the page as a form.
4. Create a node with a webform field referring to the form in Step 2.
5. Visit the node created in Step 4, create a form submission on that page.
6. Create a page_manager page overriding /node/{node}/webform/submission/{webform_submission}.
6a. Make the type of the page a Layout Builder.
6b. Put anything on the layout of the only variant (e.g. Powered by Drupal).
7. View the submission created in Step 5 via the /node/{node}/webform/submission/{webform_submission} route.

On Step 7, you will see the error mentioned above.

Proposed resolution

- Preserve overridden route's defaults maybe?
- Or have page_manager resolve the parameters from the original route if it can't be found on itself maybe?

Remaining tasks

- Investigate.
- Patch?
- Review?
- Merge?

User interface changes

None

API changes

Potentially changes what the page_manager page's $route default property contains.

Data model changes

None

πŸ› Bug report
Status

Needs review

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States fskreuz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024