From 07bd1e03d0b9321d8f8d382d08825d98e89ff6dc Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 1 Oct 2021 11:42:41 -0600 Subject: [PATCH] Better backwards compatibility --- system/blueprints/config/system.yaml | 2 +- system/config/system.yaml | 2 +- system/src/Grav/Common/HTTP/Client.php | 23 ++++++++++++++--------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/system/blueprints/config/system.yaml b/system/blueprints/config/system.yaml index 43679a11e..1aeaf2bf2 100644 --- a/system/blueprints/config/system.yaml +++ b/system/blueprints/config/system.yaml @@ -1492,7 +1492,7 @@ form: options: 1: PLUGIN_ADMIN.YES 0: PLUGIN_ADMIN.NO - default: true + default: false validate: type: bool diff --git a/system/config/system.yaml b/system/config/system.yaml index 140a95246..47151d3f7 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -188,7 +188,7 @@ gpm: http: method: auto # Either 'curl', 'fopen' or 'auto'. 'auto' will try fopen first and if not available cURL - enable_proxy: false # Enabled proxy server + enable_proxy: true # Enable proxy server configuration proxy_url: # Configure a manual proxy URL for GPM (eg 127.0.0.1:3128) proxy_cert_path: # Local path to proxy certificate folder containing pem files concurrent_connections: 5 # Concurrent HTTP connections when multiplexing diff --git a/system/src/Grav/Common/HTTP/Client.php b/system/src/Grav/Common/HTTP/Client.php index d0d524dfb..867748f65 100644 --- a/system/src/Grav/Common/HTTP/Client.php +++ b/system/src/Grav/Common/HTTP/Client.php @@ -37,7 +37,11 @@ class Client } $settings = array_merge($options->toArray(), $overrides); - $preferred_method = $config->get('system.http.method', $config->get('system.gpm.method', 'auto')); + $preferred_method = $config->get('system.http.method'); + // Try old GPM setting if value is the same as system default + if ($preferred_method === 'auto') { + $preferred_method = $config->get('system.gpm.method', 'auto'); + } switch ($preferred_method) { case 'curl': @@ -70,17 +74,18 @@ class Client $options->setHeaders(array_merge([ 'Referer' => $referer ], self::$headers)); // Disable verify Peer if required - $verify_peer = $config->get('system.http.verify_peer', $config->get('system.gpm.verify_peer', null)); - if ($verify_peer !== null) { - $options->verifyPeer($verify_peer); + $verify_peer = $config->get('system.http.verify_peer'); + // Try old GPM setting if value is default + if ($verify_peer === true) { + $verify_peer = $config->get('system.gpm.verify_peer', null) ?? $verify_peer; } + $options->verifyPeer($verify_peer); - // Disable verify Host if required - $verify_host = $config->get('system.http.verify_host', null); - if ($verify_host !== null) { - $options->verifyHost($verify_host); - } + // Set verify Host + $verify_host = $config->get('system.http.verify_host', true); + $options->verifyHost($verify_host); + // New setting and must be enabled for Proxy to work if ($config->get('system.http.enable_proxy', true)) { // Set proxy url if provided $proxy_url = $config->get('system.http.proxy_url', $config->get('system.gpm.proxy_url', null));