Problem/Motivation
My Drupal installation contains a tab for nodes just like the one Quick Node Clone creates. It worked fine until I installed Quick Node Clone. When this Tab is clicked after installing Quick Node Clone it crashes with an error in QuickNodeCloneNodeAccess.php.
The error message is:
RuntimeException: Callable "Drupal\quick_node_clone\Controller\QuickNodeCloneNodeAccess::cloneNode" requires a value for the "$node" argument. in Drupal\Component\Utility\ArgumentsResolver->handleUnresolvedArgument() (line 149 of core/lib/Drupal/Component/Utility/ArgumentsResolver.php).
I am not sure if the problem is caused by my tab or by Quick Node Clone. I describe the problem here because the error message points to Quick Node Clone and I could solve it with a patch to QuickNodeCloneNodeAccess.php. So maybe it helps someone with the same problem. I attached the patch to this issue.
Steps to reproduce
Create a tab for nodes. Here is the code.
In my_module.links.task.yml
my_module.add.products.tab:
route_name: my_module.add.products.view
title: 'My Title'
base_route: entity.node.canonical
weight: 15
In my_module.routing.yml:
my_module.add.products.view:
path: '/admin/add_product'
defaults:
_controller: '\Drupal\my_module\Controller\MyController::myFunction'
_title: 'My Title'
requirements:
_access: 'TRUE'
In MyController::myFunction do something and return $build
Now test if everything works and the tab is displayed as expected. If so, install Quick Node Clone.
Click your Tab again and it produces the above mentioned error. Debugging shows, that QuickNodeCloneNodeAccess.php is called twice, once with the $node parameter and once without it.
Proposed resolution
Give $node a default value of null in the function parameters and return AccessResult::neutral() if the parameter is missing.
See the attached patch.