Error - ContactPageAccess::access" requires a value for the "$user" argument

Created on 29 June 2018, about 6 years ago
Updated 27 October 2023, 11 months ago

Hi. I have a problem with D8.

Steps to reproduce error:
1. Create node and get id for it.
2. Create module and file my_module.links.task.yml with next context:

my_module.user_profile.layout.dashboard:
  title: 'Site rules'
  route_name: entity.node.canonical
  base_route: entity.user.canonical
  route_parameters:
    node: 1

This will add tab to user profile page with site rules(for example).
3. Go to user profile page and click on tab.
4. Get error.
RuntimeException: Callable "Drupal\contact\Access\ContactPageAccess::access" requires a value for the "$user" argument. in Drupal\Component\Utility\ArgumentsResolver->handleUnresolvedArgument() (line 142 of /var/www/my_site/web/core/lib/Drupal/Component/Utility/ArgumentsResolver.php).

I think it is problem of menu system because root of error in LocalTaskManager.

What can I do to avoid this error?
Is it bug in core or I can make something in my module?

πŸ’¬ Support request
Status

Closed: outdated

Version

9.3

Component
Menu systemΒ  β†’

Last updated 1 day ago

Created by

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.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Strange thing, I just ran into this message on a Drupal 10.1 page.
    It's also a further tab on the user profile page (for Homebox 3.0.x).

    I also found #2883266: RuntimeException: Callable "Drupal\contact\Access\ContactPageAccess::access" requires a value for the "$user" argument. in Drupal\Component\Utility\ArgumentsResolver->handleUnresolvedArgument() β†’ :
    But no view and no usage of contact module (which is just enabled by default on the vanilla DDEV installation).

    This is the implementation I'm using:

    /**
     * Implements hook_local_tasks_alter().
     *
     * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
     * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
     */
    function homebox_local_tasks_alter(&$local_tasks) {
      // Add route to display on the user profile page.
      $homeboxTypeStorage = \Drupal::entityTypeManager()->getStorage('homebox_type');
      $homeboxTypes = $homeboxTypeStorage->loadMultiple();
      $userId = \Drupal::currentUser()->id();
      /** @var \Drupal\homebox\Entity\HomeboxTypeInterface $homeboxType */
      foreach ($homeboxTypes as $homeboxType) {
        if ($homeboxType->getUserTabEnabled()) {
          $local_tasks['homebox.user_profile.homebox_type.' . $homeboxType->id()] = [
            'id' => 'homebox.user_profile.homebox_type.' . $homeboxType->id(),
            'title' => $homeboxType->label(),
            'route_name' => 'homebox.user_tab',
            'base_route' => 'entity.user.canonical',
            'weight' => -100,
            'route_parameters' => [
              'homebox_type' => $homeboxType->id(),
              'owner' => $userId,
            ],
            'class' => '\Drupal\Core\Menu\LocalTaskDefault',
            'provider' => 'homebox',
            'options' => [],
          ];
        }
      }
    }
    

    Perhaps it helps someone to find the root cause. For now I'll just remove the old contact module ;)

Production build 0.71.5 2024