From 4476b9a97ad03776a72c1b1c1cb540109968f56c Mon Sep 17 00:00:00 2001 From: Craig Heydenburg Date: Tue, 23 Jun 2015 09:11:14 -0400 Subject: [PATCH 1/2] disable (at least temporarily) 'advanced' handling of RouteNotFoundException. The redirects have caused issues before and can cause endless redirects. There are specific issues when `adminpanelmenu` is in use because it expects routes to be available. This PR reduces handling to be the same error message for admin and normal users. refs #2470 (probably) --- .../EventListener/ExceptionListener.php | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/lib/Zikula/Bundle/CoreBundle/EventListener/ExceptionListener.php b/src/lib/Zikula/Bundle/CoreBundle/EventListener/ExceptionListener.php index 96ef77e615..7141b3fb80 100644 --- a/src/lib/Zikula/Bundle/CoreBundle/EventListener/ExceptionListener.php +++ b/src/lib/Zikula/Bundle/CoreBundle/EventListener/ExceptionListener.php @@ -124,22 +124,22 @@ private function handleRouteNotFoundException(GetResponseForExceptionEvent $even { $message = $event->getException()->getMessage(); $event->getRequest()->getSession()->getFlashBag()->add('error', $message); - if ($userLoggedIn && \SecurityUtil::checkPermission('ZikulaRoutesModule::', '::', ACCESS_ADMIN)) { - $originalRouteCollection = $this->router->getOriginalRouteCollection()->all(); - if (!array_key_exists('zikularoutesmodule_route_reload', $originalRouteCollection)) { - // reload routes for the Routes module first - $this->routesControllerUtil->reloadRoutesByModule('ZikulaRoutesModule'); - $this->cacheClearer->clear("symfony.routing"); - } - $url = $this->router->generate('zikularoutesmodule_route_reload', array('lct' => 'admin'), RouterInterface::ABSOLUTE_URL); - $frontController = \System::getVar('entrypoint', 'index.php'); - if (strpos($url, "$frontController/") !== false) { - $url = str_ireplace("$frontController/", "", $url); - } - $event->getRequest()->getSession()->getFlashBag()->add('error', __('You might try re-loading the routes for the extension in question.')); - $event->setResponse(new RedirectResponse($url)); - $event->stopPropagation(); - } +// if ($userLoggedIn && \SecurityUtil::checkPermission('ZikulaRoutesModule::', '::', ACCESS_ADMIN)) { +// $originalRouteCollection = $this->router->getOriginalRouteCollection()->all(); +// if (!array_key_exists('zikularoutesmodule_route_reload', $originalRouteCollection)) { +// // reload routes for the Routes module first +// $this->routesControllerUtil->reloadRoutesByModule('ZikulaRoutesModule'); +// $this->cacheClearer->clear("symfony.routing"); +// } +// $url = $this->router->generate('zikularoutesmodule_route_reload', array('lct' => 'admin'), RouterInterface::ABSOLUTE_URL); +// $frontController = \System::getVar('entrypoint', 'index.php'); +// if (strpos($url, "$frontController/") !== false) { +// $url = str_ireplace("$frontController/", "", $url); +// } +// $event->getRequest()->getSession()->getFlashBag()->add('error', __('You might try re-loading the routes for the extension in question.')); +// $event->setResponse(new RedirectResponse($url)); +// $event->stopPropagation(); +// } } /** From 8ba9416a3dd80766ed7294d4f40ac67f06be374c Mon Sep 17 00:00:00 2001 From: Craig Heydenburg Date: Tue, 23 Jun 2015 13:51:07 -0400 Subject: [PATCH 2/2] provide link to reload routes if available. --- .../CoreBundle/EventListener/ExceptionListener.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lib/Zikula/Bundle/CoreBundle/EventListener/ExceptionListener.php b/src/lib/Zikula/Bundle/CoreBundle/EventListener/ExceptionListener.php index 7141b3fb80..b5f1b41801 100644 --- a/src/lib/Zikula/Bundle/CoreBundle/EventListener/ExceptionListener.php +++ b/src/lib/Zikula/Bundle/CoreBundle/EventListener/ExceptionListener.php @@ -124,8 +124,13 @@ private function handleRouteNotFoundException(GetResponseForExceptionEvent $even { $message = $event->getException()->getMessage(); $event->getRequest()->getSession()->getFlashBag()->add('error', $message); -// if ($userLoggedIn && \SecurityUtil::checkPermission('ZikulaRoutesModule::', '::', ACCESS_ADMIN)) { -// $originalRouteCollection = $this->router->getOriginalRouteCollection()->all(); + if ($userLoggedIn && \SecurityUtil::checkPermission('ZikulaRoutesModule::', '::', ACCESS_ADMIN)) { + $originalRouteCollection = $this->router->getOriginalRouteCollection()->all(); + if (array_key_exists('zikularoutesmodule_route_reload', $originalRouteCollection)) { + $url = $this->router->generate('zikularoutesmodule_route_reload', array('lct' => 'admin'), RouterInterface::ABSOLUTE_URL); + $link = "". __('re-loading the routes') . ""; + $event->getRequest()->getSession()->getFlashBag()->add('error', __f('You might try %s for the extension in question.', $link)); + } // if (!array_key_exists('zikularoutesmodule_route_reload', $originalRouteCollection)) { // // reload routes for the Routes module first // $this->routesControllerUtil->reloadRoutesByModule('ZikulaRoutesModule'); @@ -139,7 +144,7 @@ private function handleRouteNotFoundException(GetResponseForExceptionEvent $even // $event->getRequest()->getSession()->getFlashBag()->add('error', __('You might try re-loading the routes for the extension in question.')); // $event->setResponse(new RedirectResponse($url)); // $event->stopPropagation(); -// } + } } /**