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". * Whether we can or can't show the "thing".
*/ */
public function access(RouteMatch $route_match) { 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')) { if ($route_match->getParameters()->has('node')) {
$node = $route_match->getParameter('node'); $node = $route_match->getParameter('node');
if (!$node instanceof NodeInterface) { if (!$node instanceof NodeInterface) {
$node = Node::load($node); $node = Node::load($node);
} }
if ($this->utils->isIslandoraType($node->getEntityTypeId(), $node->bundle())) { // Ensure there's actually a node before referencing it.
return AccessResult::allowed(); if ($node) {
if ($this->utils->isIslandoraType($node->getEntityTypeId(), $node->bundle())) {
return AccessResult::allowed();
}
} }
} }
return AccessResult::forbidden(); return AccessResult::forbidden();

Loading…
Cancel
Save