From aebb349543dcb8d4b3b0ff74d368e33cb9edcb26 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Fri, 16 Aug 2019 14:40:15 -0400 Subject: [PATCH 1/3] Update CI stuff --- .travis.yml | 1 - Jenkinsfile | 24 ++++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 766e0c4b..391585d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ php: - 7.1 - 7.2 - 7.3 - - hhvm - nightly script: diff --git a/Jenkinsfile b/Jenkinsfile index ac979353..11dc7110 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,8 +4,8 @@ pipeline { stage('PHP 7.1') { agent { docker { - image 'php:7.1-alpine' - args '-u root --privileged' + image 'php:7.1-alpine' + args '-u root --privileged' } } steps { @@ -20,8 +20,8 @@ pipeline { stage('PHP 7.2') { agent { docker { - image 'php:7.2-alpine' - args '-u root --privileged' + image 'php:7.2-alpine' + args '-u root --privileged' } } steps { @@ -33,5 +33,21 @@ pipeline { sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never' } } + stage('PHP 7.3') { + agent { + docker { + image 'php:7.3-alpine' + args '-u root --privileged' + } + } + steps { + sh 'chmod +x ./build/docker_install.sh' + sh 'sh build/docker_install.sh' + sh 'apk add --no-cache php7-phpdbg' + sh 'curl -sS https://getcomposer.org/installer | php' + sh 'php composer.phar install --ignore-platform-reqs' + sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never' + } + } } } \ No newline at end of file From 117427ced0624c71f0fb15307397d3e72134dd2d Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Mon, 7 Oct 2019 20:10:27 -0400 Subject: [PATCH 2/3] Misc bugfixes, especially for Anime without a MAL id. --- src/API/Anilist/Model.php | 5 +++++ src/Model/Anime.php | 4 ++-- src/Types/AbstractType.php | 15 ++++++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/API/Anilist/Model.php b/src/API/Anilist/Model.php index 6626cf18..1dfbbe37 100644 --- a/src/API/Anilist/Model.php +++ b/src/API/Anilist/Model.php @@ -274,6 +274,11 @@ final class Model 'type' => mb_strtoupper($type), ]); + if (empty($info) || empty($info['data'])) + { + return NULL; + } + return (string)$info['data']['Media']['id']; } } \ No newline at end of file diff --git a/src/Model/Anime.php b/src/Model/Anime.php index 4de786c0..213a8bc3 100644 --- a/src/Model/Anime.php +++ b/src/Model/Anime.php @@ -187,7 +187,7 @@ class Anime extends API { $requester = new ParallelAPIRequest(); $requester->addRequest($this->kitsuModel->incrementListItem($data), 'kitsu'); - if ($this->anilistEnabled && $data['mal_id'] !== null) + if (( ! empty($data['mal_id'])) && $this->anilistEnabled) { $requester->addRequest($this->anilistModel->incrementListItem($data, 'ANIME'), 'anilist'); } @@ -214,7 +214,7 @@ class Anime extends API { $requester = new ParallelAPIRequest(); $requester->addRequest($this->kitsuModel->updateListItem($data), 'kitsu'); - if ($this->anilistEnabled && $data['mal_id'] !== null) + if (( ! empty($data['mal_id'])) && $this->anilistEnabled) { $requester->addRequest($this->anilistModel->updateListItem($data, 'ANIME'), 'anilist'); } diff --git a/src/Types/AbstractType.php b/src/Types/AbstractType.php index 5f9740b5..6c04ffd6 100644 --- a/src/Types/AbstractType.php +++ b/src/Types/AbstractType.php @@ -17,8 +17,10 @@ namespace Aviat\AnimeClient\Types; use ArrayAccess; +use ArrayObject; +use Countable; -abstract class AbstractType implements ArrayAccess { +abstract class AbstractType implements ArrayAccess, Countable { /** * Populate values for un-serializing data * @@ -164,6 +166,17 @@ abstract class AbstractType implements ArrayAccess { } } + /** + * Implementing Countable + * + * @return int + */ + public function count(): int + { + $keys = array_keys($this->toArray()); + return count($keys); + } + /** * Recursively cast properties to an array * From cd835055ecebb7820a9093082b67e2cc11d5cd2e Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Tue, 8 Oct 2019 19:59:47 -0400 Subject: [PATCH 3/3] Catch errors when mapping MAL ids on sync --- src/API/Anilist/Model.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/API/Anilist/Model.php b/src/API/Anilist/Model.php index 1dfbbe37..00115399 100644 --- a/src/API/Anilist/Model.php +++ b/src/API/Anilist/Model.php @@ -269,12 +269,17 @@ final class Model */ private function getMediaIdFromMalId(string $malId, string $type = 'ANIME'): ?string { + if ($malId === '') + { + return NULL; + } + $info = $this->runQuery('MediaIdByMalId', [ 'id' => $malId, 'type' => mb_strtoupper($type), ]); - if (empty($info) || empty($info['data'])) + if (array_key_exists('errors', $info)) { return NULL; }