Browse Source

Ensure node exists before using it. (#864)

pull/866/head
Jordan Dukart 3 years ago committed by GitHub
parent
commit
4c439d4817
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/Controller/ManageMediaController.php

10
src/Controller/ManageMediaController.php

@ -45,13 +45,19 @@ class ManageMediaController extends ManageMembersController {
* Whether we can or can't show the "thing".
*/
public function access(RouteMatch $route_match) {
// Route match is being used as opposed to slugs as there are a few
// admin routes being altered.
// @see: \Drupal\islandora\EventSubscriber\AdminViewsRouteSubscriber::alterRoutes().
if ($route_match->getParameters()->has('node')) {
$node = $route_match->getParameter('node');
if (!$node instanceof NodeInterface) {
$node = Node::load($node);
}
if ($this->utils->isIslandoraType($node->getEntityTypeId(), $node->bundle())) {
return AccessResult::allowed();
// Ensure there's actually a node before referencing it.
if ($node) {
if ($this->utils->isIslandoraType($node->getEntityTypeId(), $node->bundle())) {
return AccessResult::allowed();
}
}
}
return AccessResult::forbidden();

Loading…
Cancel
Save