From 37131d37759e983929b16fc7eb9ce7dd675f7b78 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Wed, 23 Jan 2019 09:19:26 -0500 Subject: [PATCH] Remove non-functional curl service driver for now Its requiring extensive configuration to function makes me disinclined to revive it, though it may nevertheless happen. --- lib/Conf.php | 8 +--- lib/Service/Curl/Driver.php | 77 ------------------------------------- locale/en.php | 1 - 3 files changed, 1 insertion(+), 85 deletions(-) delete mode 100644 lib/Service/Curl/Driver.php diff --git a/lib/Conf.php b/lib/Conf.php index 3f8f5f25..ce092e93 100644 --- a/lib/Conf.php +++ b/lib/Conf.php @@ -75,19 +75,13 @@ class Conf { * @see https://en.wikipedia.org/wiki/ISO_8601#Durations */ public $userSessionLifetime = "P7D"; - /** @var string Feed update service driver to use, one of "serial", "subprocess", or "curl". A fully-qualified class name may also be used for custom drivers */ + /** @var string Feed update service driver to use, one of "serial" or "subprocess". A fully-qualified class name may also be used for custom drivers */ public $serviceDriver = "subprocess"; /** @var \DateInterval The interval between checks for new articles, as an ISO 8601 duration * @see https://en.wikipedia.org/wiki/ISO_8601#Durations */ public $serviceFrequency = "PT2M"; /** @var integer Number of concurrent feed updates to perform */ public $serviceQueueWidth = 5; - /** @var string The base server address (with scheme, host, port if necessary, and terminal slash) to connect to the server when performing feed updates using cURL */ - public $serviceCurlBase = "http://localhost/"; - /** @var string The user name to use when performing feed updates using cURL */ - public $serviceCurlUser = ""; - /** @var string The password to use when performing feed updates using cURL */ - public $serviceCurlPassword = ""; /** @var \DateInterval Number of seconds to wait for data when fetching feeds from foreign servers */ public $fetchTimeout = 10; diff --git a/lib/Service/Curl/Driver.php b/lib/Service/Curl/Driver.php deleted file mode 100644 index cfb73d48..00000000 --- a/lib/Service/Curl/Driver.php +++ /dev/null @@ -1,77 +0,0 @@ -msg("Driver.Service.Curl.Name"); - } - - public static function requirementsMet(): bool { - return extension_loaded("curl"); - } - - public function __construct() { - //default curl options for individual requests - $this->options = [ - \CURLOPT_URL => Arsse::$serviceCurlBase."index.php/apps/news/api/v1-2/feeds/update", - \CURLOPT_CUSTOMREQUEST => "GET", - \CURLOPT_FAILONERROR => false, - \CURLOPT_FOLLOWLOCATION => false, - \CURLOPT_FORBID_REUSE => false, - \CURLOPT_CONNECTTIMEOUT => 20, - \CURLOPT_DNS_CACHE_TIMEOUT => 360, // FIXME: this should probably be twice the update-check interval so that the DNS cache is always in memory - \CURLOPT_PROTOCOLS => \CURLPROTO_HTTP | \CURLPROTO_HTTPS, - \CURLOPT_DEFAULT_PROTOCOL => "https", - \CURLOPT_USERAGENT => Arsse::$conf->fetchUserAgentString, - \CURLMOPT_MAX_HOST_CONNECTIONS => Arsse::$conf->serviceQueueWidth, - \CURLOPT_HTTPHEADER => [ - 'Accept: application/json', - 'Content-Type: application/json', - ], - \CURLOPT_HEADER => false, - ]; - // start an async session - $this->queue = curl_multi_init(); - // enable pipelining - curl_multi_setopt($this->queue, \CURLMOPT_PIPELINING, 1); - } - - public function queue(int ...$feeds): int { - foreach ($feeds as $id) { - $h = curl_init(); - curl_setopt($h, \CURLOPT_POSTFIELDS, json_encode(['userId' => "", 'feedId' => $id])); - $this->handles[] = $h; - curl_multi_add_handle($this->queue, $h); - } - return sizeof($this->handles); - } - - public function exec(): int { - $active = 0; - do { - curl_multi_exec($this->queue, $active); - curl_multi_select($this->queue); - } while ($active > 0); - return Arsse::$conf->serviceQueueWidth - $active; - } - - public function clean(): bool { - foreach ($this->handles as $h) { - curl_multi_remove_handle($this->queue, $h); - curl_close($h); - } - $this->handles = []; - return true; - } -} diff --git a/locale/en.php b/locale/en.php index dcaa8484..4c645e16 100644 --- a/locale/en.php +++ b/locale/en.php @@ -27,7 +27,6 @@ return [ 'Driver.Service.Serial.Name' => 'Serialized', 'Driver.Service.Subprocess.Name' => 'Concurrent subprocess', - 'Driver.Service.Curl.Name' => 'Concurrent HTTP (curl)', 'Driver.User.Internal.Name' => 'Internal',