From: Hypolite Petovan Date: Fri, 16 Oct 2020 01:45:51 +0000 (-0400) Subject: Centralize routes file existence check in App\Router X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=06e329441561cd91f6f4039243c23bc8bc8def45;p=friendica.git Centralize routes file existence check in App\Router --- diff --git a/src/App/Router.php b/src/App/Router.php index d27a9c1ae9..e90cb3ace0 100644 --- a/src/App/Router.php +++ b/src/App/Router.php @@ -93,6 +93,10 @@ class Router $this->routeCollector = isset($routeCollector) ? $routeCollector : new RouteCollector(new Std(), new GroupCountBased()); + + if ($this->baseRoutesFilepath && !file_exists($this->baseRoutesFilepath)) { + throw new HTTPException\InternalServerErrorException('Routes file path does\'n exist.'); + } } /** @@ -249,7 +253,7 @@ class Router { $dispatchData = []; - if ($this->baseRoutesFilepath && file_exists($this->baseRoutesFilepath)) { + if ($this->baseRoutesFilepath) { $dispatchData = require $this->baseRoutesFilepath; if (!is_array($dispatchData)) { throw new HTTPException\InternalServerErrorException('Invalid base routes file'); @@ -280,7 +284,7 @@ class Router $lastRoutesFileModifiedTime = $this->cache->get('lastRoutesFileModifiedTime'); $forceRecompute = false; - if ($this->baseRoutesFilepath && file_exists($this->baseRoutesFilepath)) { + if ($this->baseRoutesFilepath) { $routesFileModifiedTime = filemtime($this->baseRoutesFilepath); $forceRecompute = $lastRoutesFileModifiedTime != $routesFileModifiedTime; }