From 36e9f2e30a846369be4199f49889d2b5f1e96093 Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Wed, 29 Mar 2023 00:00:00 +0000 Subject: [PATCH] Fixed routing when site-slug is boolean false. --- application/src/Mvc/MvcListeners.php | 8 +++++--- application/src/Mvc/Status.php | 2 +- application/src/View/Helper/CurrentSite.php | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/application/src/Mvc/MvcListeners.php b/application/src/Mvc/MvcListeners.php index a9e2c52d5d..27a097867d 100644 --- a/application/src/Mvc/MvcListeners.php +++ b/application/src/Mvc/MvcListeners.php @@ -293,9 +293,7 @@ public function prepareAdmin(MvcEvent $event) $event->getViewModel()->setTemplate('layout/layout-admin'); - if ($routeMatch->getParam('__SITEADMIN__') - && $routeMatch->getParam('site-slug') - ) { + if ($routeMatch->getParam('__SITEADMIN__')) { $this->prepareSite($event); } } @@ -388,6 +386,10 @@ protected function prepareSite(MvcEvent $event) $services = $event->getApplication()->getServiceManager(); $siteSlug = $event->getRouteMatch()->getParam('site-slug'); + if (!is_string($siteSlug) || !strlen($siteSlug)) { + return false; + } + try { $site = $services->get('Omeka\ApiManager') ->read('sites', ['slug' => $siteSlug])->getContent(); diff --git a/application/src/Mvc/Status.php b/application/src/Mvc/Status.php index a870367e3e..91548bd5fe 100644 --- a/application/src/Mvc/Status.php +++ b/application/src/Mvc/Status.php @@ -64,7 +64,7 @@ public function setIsInstalled($isInstalled) /** * Get the route match. * - * @return Laminas\Router\Http\RouteMatch + * @return \Laminas\Router\Http\RouteMatch */ public function getRouteMatch() { diff --git a/application/src/View/Helper/CurrentSite.php b/application/src/View/Helper/CurrentSite.php index c7c023e0f1..8b65e6e50e 100644 --- a/application/src/View/Helper/CurrentSite.php +++ b/application/src/View/Helper/CurrentSite.php @@ -5,7 +5,7 @@ use Laminas\View\Helper\AbstractHelper; /** - * CView helper for getting the current site representation. + * View helper for getting the current site representation. */ class CurrentSite extends AbstractHelper {