refactor: display action (#3508)

This commit is contained in:
Dag 2023-07-08 17:06:33 +02:00 committed by GitHub
parent c1c8304fc0
commit 8b996e3056
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 13 deletions

View File

@ -38,22 +38,22 @@ class DisplayAction implements ActionInterface
$bridge = $bridgeFactory->create($bridgeClassName); $bridge = $bridgeFactory->create($bridgeClassName);
$bridge->loadConfiguration(); $bridge->loadConfiguration();
$noproxy = array_key_exists('_noproxy', $request) && filter_var($request['_noproxy'], FILTER_VALIDATE_BOOLEAN); $noproxy = $request['_noproxy'] ?? null;
if (
if (Configuration::getConfig('proxy', 'url') && Configuration::getConfig('proxy', 'by_bridge') && $noproxy) { Configuration::getConfig('proxy', 'url')
&& Configuration::getConfig('proxy', 'by_bridge')
&& $noproxy
) {
// This const is only used once in getContents()
define('NOPROXY', true); define('NOPROXY', true);
} }
if (array_key_exists('_cache_timeout', $request)) { $cacheTimeout = $request['_cache_timeout'] ?? null;
if (! Configuration::getConfig('cache', 'custom_timeout')) { if (Configuration::getConfig('cache', 'custom_timeout') && $cacheTimeout) {
unset($request['_cache_timeout']); $cacheTimeout = (int) $cacheTimeout;
$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);
} else { } 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 // Remove parameters that don't concern bridges
@ -99,7 +99,7 @@ class DisplayAction implements ActionInterface
if ( if (
$mtime $mtime
&& (time() - $cache_timeout < $mtime) && (time() - $cacheTimeout < $mtime)
&& !Debug::isEnabled() && !Debug::isEnabled()
) { ) {
// At this point we found the feed in the cache and debug mode is disabled // At this point we found the feed in the cache and debug mode is disabled