1

I want to set a breakpoint in xdebug to debug an interesting issue the site is having regarding user access to certain nodes. My question is where do I do that in D8? Where, specifically, is the D8 replacement for user_access to be found?

Not using any form of node access, but am using Group and Content Moderation. The problem could lie with either of them, but I thought the best approach would be to break where Drupal decides whether a user has access to node/###/edit, then step from there.

The problem is that the user's role's permissions give all node and content moderation permissions for the applicable content type. Yet, when going to the admin/content page or admin/content/moderation, given two nodes of the same content type authored by a user of the given role, with the same node and moderation status, only one has an edit button. In viewing the nodes, only one has an edit link.

I have rebuilt permissions, to no effect.

2 Answers 2

2

The /node/{node}/edit path is defined by the entity.node.edit_form route. This route uses the _entity_access requirement to lookup access. When that route's requested the entity API will execute EntityAccessCheck::access() and NodeAccessControlHandler::access() to lookup the account permssions for the relevant node.

1

I found the best place to put debug code is in \Drupal\Core\Access\AccessManager::check. In my case...

    $result = AccessResult::neutral();
if (!empty($checks)) {
  $arguments_resolver = $this->argumentsResolverFactory->getArgumentsResolver($route_match, $account, $request);
  $result = AccessResult::allowed();
  foreach ($checks as $service_id) {
    $result = $result->andIf($this->performCheck($service_id, $arguments_resolver));
    // Begin debug
    if($route_match->getRouteName() == 'entity.node.edit_form') {
      $this_check = $this->performCheck($service_id, $arguments_resolver);
      dpm(compact('service_id', 'this_check'), __FILE__ . ":" . __LINE__);
    }
    // End debug
  }
}
// Begin debug
if($route_match->getRouteName() == 'entity.node.edit_form') {
  dpm($result, __FILE__ . ":" . __LINE__);
}
// End debug
return $return_as_object ? $result : $result->isAllowed();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.