From 4c439d48171220468304ca5e1ade7badf97370f6 Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Fri, 25 Mar 2022 12:47:40 -0300 Subject: [PATCH] Ensure node exists before using it. (#864) --- src/Controller/ManageMediaController.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Controller/ManageMediaController.php b/src/Controller/ManageMediaController.php index 56e0b5c5..bd670561 100644 --- a/src/Controller/ManageMediaController.php +++ b/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();