From 8b996e30563988ea83f5dc3c972909a959146437 Mon Sep 17 00:00:00 2001 From: Dag Date: Sat, 8 Jul 2023 17:06:33 +0200 Subject: [PATCH] refactor: display action (#3508) --- actions/DisplayAction.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/actions/DisplayAction.php b/actions/DisplayAction.php index cc910b45..66acd4cc 100644 --- a/actions/DisplayAction.php +++ b/actions/DisplayAction.php @@ -38,22 +38,22 @@ class DisplayAction implements ActionInterface $bridge = $bridgeFactory->create($bridgeClassName); $bridge->loadConfiguration(); - $noproxy = array_key_exists('_noproxy', $request) && filter_var($request['_noproxy'], FILTER_VALIDATE_BOOLEAN); - - if (Configuration::getConfig('proxy', 'url') && Configuration::getConfig('proxy', 'by_bridge') && $noproxy) { + $noproxy = $request['_noproxy'] ?? null; + if ( + Configuration::getConfig('proxy', 'url') + && Configuration::getConfig('proxy', 'by_bridge') + && $noproxy + ) { + // This const is only used once in getContents() define('NOPROXY', true); } - if (array_key_exists('_cache_timeout', $request)) { - if (! Configuration::getConfig('cache', 'custom_timeout')) { - unset($request['_cache_timeout']); - $uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) . '?' . http_build_query($request); - return new Response('', 301, ['Location' => $uri]); - } - - $cache_timeout = filter_var($request['_cache_timeout'], FILTER_VALIDATE_INT); + $cacheTimeout = $request['_cache_timeout'] ?? null; + if (Configuration::getConfig('cache', 'custom_timeout') && $cacheTimeout) { + $cacheTimeout = (int) $cacheTimeout; } else { - $cache_timeout = $bridge->getCacheTimeout(); + // At this point the query argument might still be in the url but it won't be used + $cacheTimeout = $bridge->getCacheTimeout(); } // Remove parameters that don't concern bridges @@ -99,7 +99,7 @@ class DisplayAction implements ActionInterface if ( $mtime - && (time() - $cache_timeout < $mtime) + && (time() - $cacheTimeout < $mtime) && !Debug::isEnabled() ) { // At this point we found the feed in the cache and debug mode is disabled