Problem
When attempting to use $menuLinkContent->access('randomoperation')
an exception is thrown.
The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to Drupal\Core\Access\AccessResult::orIf() must implement interface Drupal\Core\Access\AccessResultInterface, null given, called in /core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php on line 106 in Drupal\Core\Access\AccessResult->orIf() (line 314 of core/lib/Drupal/Core/Access/AccessResult.php).
Drupal\Core\Access\AccessResult->orIf(NULL) (Line: 106)
Drupal\Core\Entity\EntityAccessControlHandler->access(Object, 'clone', Object, ) (Line: 708)
Drupal\Core\Entity\ContentEntityBase->access('clone') (Line: 32)
Cause
\Drupal\menu_link_content\MenuLinkContentAccessControlHandler::checkAccess
must always return an object implementing \Drupal\Core\Access\AccessResultInterface
. However it incorrectly returns NULL when an access to an operation other than 'view', 'update', or 'delete' is requested.
Motivation
Entity Clone automatically adds a 'Clone' local task to content entities. Patch #2743379: Clone operation shows regardless of permission for Entity Clone updates its clone route to use a 'clone' operation. However because Menu Link Content mishandles unrecognised operations, the menu link page edit form throws an exception.