From ac57381d2dae723fa7c450366c47485c9b150d68 Mon Sep 17 00:00:00 2001 From: Jean-Yves Roda Date: Sat, 22 Aug 2020 17:28:33 +0200 Subject: [PATCH 1/2] API switched to https, but mirrors.xml still reports http endpoint. Quick fix using the provided tvdb URL --- README.md | 4 ++-- examples/settings.php.dist | 2 +- src/Moinax/TvDb/Client.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5ebba74..5827e7e 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Usage: use Moinax\TvDb\Client; $apiKey = 'YOURAPIKEY'; -$tvdb = new Client("http://thetvdb.com", $apiKey); +$tvdb = new Client("https://thetvdb.com", $apiKey); $tvdb->getSerie(75710); ``` @@ -42,7 +42,7 @@ $apiKey = 'YOURAPIKEY'; $cache = new FilesystemCache(__DIR__ . '/cache'); $httpClient = new CacheClient($cache, $ttl); -$tvdb = new Client("http://thetvdb.com", $apiKey); +$tvdb = new Client("https://thetvdb.com", $apiKey); $tvdb->setHttpClient($httpClient); $tvdb->getSerie(75710); //This request will fetch the resource online. diff --git a/examples/settings.php.dist b/examples/settings.php.dist index b46d35d..89ae364 100644 --- a/examples/settings.php.dist +++ b/examples/settings.php.dist @@ -3,5 +3,5 @@ * Constants defined here outside of class because class constants can't be * the result of any operation (concatenation) */ -define('TVDB_URL', 'http://thetvdb.com'); +define('TVDB_URL', 'https://thetvdb.com'); define('TVDB_API_KEY', ''); diff --git a/src/Moinax/TvDb/Client.php b/src/Moinax/TvDb/Client.php index 789cc05..97bb5bc 100644 --- a/src/Moinax/TvDb/Client.php +++ b/src/Moinax/TvDb/Client.php @@ -500,7 +500,7 @@ public function getMirror($typeMask = self::MIRROR_TYPE_XML) if (empty($this->mirrors)) { $this->getMirrors(); } - return $this->mirrors[$typeMask][array_rand($this->mirrors[$typeMask], 1)]; + return $this->baseUrl; } From 46798f669d0da383458c8ee65bef6101d77efe14 Mon Sep 17 00:00:00 2001 From: Jean-Yves Roda Date: Sat, 22 Aug 2020 17:29:36 +0200 Subject: [PATCH 2/2] When search gives no result, parsed html evaluates to FALSE even if valid. Fixes exception on no results found --- src/Moinax/TvDb/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Moinax/TvDb/Client.php b/src/Moinax/TvDb/Client.php index 97bb5bc..442d824 100644 --- a/src/Moinax/TvDb/Client.php +++ b/src/Moinax/TvDb/Client.php @@ -445,7 +445,7 @@ protected function getXml($data) } $simpleXml = simplexml_load_string($data); - if (!$simpleXml) { + if ($simpleXml === FALSE) { if (extension_loaded('libxml')) { $xmlErrors = libxml_get_errors(); $errors = array();