From 8699bb6902a0281276fe9a879f04e277b670ac61 Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Sun, 19 Apr 2020 14:24:29 +0200 Subject: [PATCH 1/3] Add carbon as dependency Restrict to the latest 5.5 & 7.x versions. --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 86a9830751..37b32d2aa4 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,7 @@ "require": { "php": ">= 7.1", "ext-json": "*", + "nesbot/carbon": "^1.26.0 || ^2.17", "illuminate/contracts": "5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0", "illuminate/http": "5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0", "illuminate/pagination": "5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0", From 1295af2c5eb6aeed7ff4b8edc562ef699b22d082 Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Sun, 19 Apr 2020 14:25:37 +0200 Subject: [PATCH 2/3] Fix TTL in subscriptions storage manager The TTL argument on cache calls is in minutes in Laravel 5.5-5.7 and changed to seconds on Laravel 5.8+, passing a Carbon instance makes sure our TTL in seconds is always correct. --- src/Subscriptions/StorageManager.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Subscriptions/StorageManager.php b/src/Subscriptions/StorageManager.php index fdbf5dd8ba..3397bb01de 100644 --- a/src/Subscriptions/StorageManager.php +++ b/src/Subscriptions/StorageManager.php @@ -2,6 +2,7 @@ namespace Nuwave\Lighthouse\Subscriptions; +use Carbon\Carbon; use Illuminate\Cache\CacheManager; use Illuminate\Support\Arr; use Illuminate\Support\Collection; @@ -78,7 +79,8 @@ public function storeSubscriber(Subscriber $subscriber, string $topic): void if ($this->ttl === null) { $this->cache->forever($channelKey, $subscriber); } else { - $this->cache->put($channelKey, $subscriber, $this->ttl); + // TODO: Change to just pass the ttl directly when support for Laravel <=5.7 is dropped + $this->cache->put($channelKey, $subscriber, Carbon::now()->addSeconds($this->ttl)); } } @@ -103,7 +105,8 @@ protected function storeTopic(string $key, Collection $topic): void if ($this->ttl === null) { $this->cache->forever($key, $topic); } else { - $this->cache->put($key, $topic, $this->ttl); + // TODO: Change to just pass the ttl directly when support for Laravel <=5.7 is dropped + $this->cache->put($key, $topic, Carbon::now()->addSeconds($this->ttl)); } } From 0949696ccf79926170ce457ca6019d9438ef20de Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Sun, 19 Apr 2020 16:06:23 +0200 Subject: [PATCH 3/3] Update Carbon constraints --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 37b32d2aa4..6b0591dff2 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "require": { "php": ">= 7.1", "ext-json": "*", - "nesbot/carbon": "^1.26.0 || ^2.17", + "nesbot/carbon": "^1.26.0 || ^2.0", "illuminate/contracts": "5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0", "illuminate/http": "5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0", "illuminate/pagination": "5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6.0 || ^7.0",