diff --git a/README.md b/README.md index 790b0df..b2d738c 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Note that this is not intended to be a full-featured feed reader. ## Installation Requirements * PHP version ≥ 8.2 +* Icinga Web2 ≥ 2.14 ## Documentation diff --git a/library/Feeds/FeedCache.php b/library/Feeds/FeedCache.php index 0869120..3186bf3 100644 --- a/library/Feeds/FeedCache.php +++ b/library/Feeds/FeedCache.php @@ -17,6 +17,11 @@ class FeedCache extends FileCache */ public function clearAll(): void { + // Probably not gonna happen but why not + if (!is_dir($this->basedir)) { + return; + } + $iterator = new FilesystemIterator($this->basedir); foreach ($iterator as $file) { if (!$file->isFile()) { diff --git a/library/Feeds/FeedReader.php b/library/Feeds/FeedReader.php index b9d1e49..82e0dbe 100644 --- a/library/Feeds/FeedReader.php +++ b/library/Feeds/FeedReader.php @@ -57,7 +57,10 @@ protected function fetchFeed(): string { $timeoutInSeconds = $this->config->get('http', 'timeout', 5); - $client = $this->client ?? new Client(['timeout' => $timeoutInSeconds]); + $client = $this->client ?? new Client([ + 'timeout' => $timeoutInSeconds, + 'connect_timeout' => $timeoutInSeconds, + ]); $response = $client->request('GET', $this->url, [ 'headers' => [ diff --git a/library/Feeds/Storage/FilesystemStorage.php b/library/Feeds/Storage/FilesystemStorage.php index d82257e..ee9e6d5 100644 --- a/library/Feeds/Storage/FilesystemStorage.php +++ b/library/Feeds/Storage/FilesystemStorage.php @@ -68,7 +68,7 @@ protected function loadFeedFile(string $filename): FeedDefinition throw new NotReadableError('Could not read file %s', $filePath); } - // This will throw an expection, which we will catch just like the others + // This will throw an exception, which we will catch just like the others $json = Json::decode($data, true); $feed = FeedDefinition::fromArray($json); @@ -100,7 +100,7 @@ protected function storeFeedFile(FeedDefinition $feed): void } /** - * removeFeedFile removes a feed's file by its anme + * removeFeedFile removes a feed's file by its name */ public function removeFeedFile(string $filename): bool { @@ -176,7 +176,7 @@ protected function load(): void try { $feed = $this->loadFeedFile($name); } catch (Exception $ex) { - Logger::error('Failed to load feed file "%s": %s', $name, $e); + Logger::error('Failed to load feed file "%s": %s', $name, $ex); continue; } diff --git a/library/Feeds/Web/FeedContent.php b/library/Feeds/Web/FeedContent.php index 4a669f0..c60f54d 100644 --- a/library/Feeds/Web/FeedContent.php +++ b/library/Feeds/Web/FeedContent.php @@ -8,7 +8,7 @@ /** * Feed content represents arbitrary feed body. - * The raw data of the body is escaped and formated for output in icingaweb2 + * The raw data of the body is escaped and formatted for output in icingaweb2 */ class FeedContent extends HtmlString { @@ -36,7 +36,7 @@ public function __construct(string $text) $text = trim($text); // Add zero-width space after commas which are not followed by a whitespace character - // in oder to help browsers to break words + // in order to help browsers to break words $text = preg_replace('/,(?=[^\s])/', ',​', $text); parent::__construct($text);