From 69aa751f40960bd49060b7bb4696116b182bdc85 Mon Sep 17 00:00:00 2001 From: Dag Date: Tue, 11 Jul 2023 23:26:22 +0200 Subject: [PATCH] fix(cache): bug in prior refactor (#3525) * fix(cache): bug in prior refactor * yup --- lib/TwitterClient.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/TwitterClient.php b/lib/TwitterClient.php index 18e8d02a..cdedcbc1 100644 --- a/lib/TwitterClient.php +++ b/lib/TwitterClient.php @@ -12,7 +12,7 @@ class TwitterClient { $this->cache = $cache; $this->authorization = 'AAAAAAAAAAAAAAAAAAAAAGHtAgAAAAAA%2Bx7ILXNILCqkSGIzy6faIHZ9s3Q%3DQy97w6SIrzE7lQwPJEYQBsArEE2fC25caFwRBvAGi456G09vGR'; - $this->data = $cache->loadData() ?? []; + $this->data = $this->cache->loadData() ?? []; } public function fetchUserTweets(string $screenName): \stdClass @@ -95,6 +95,9 @@ class TwitterClient $response = getContents($url, $this->createHttpHeaders(), [CURLOPT_POST => true]); $guest_token = json_decode($response)->guest_token; $this->data['guest_token'] = $guest_token; + + $this->cache->setScope('twitter'); + $this->cache->setKey(['cache']); $this->cache->saveData($this->data); Logger::info("Fetch new guest token: $guest_token"); } @@ -119,6 +122,9 @@ class TwitterClient } $userInfo = $response->data->user; $this->data[$screenName] = $userInfo; + + $this->cache->setScope('twitter'); + $this->cache->setKey(['cache']); $this->cache->saveData($this->data); return $userInfo; }