aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bridges/ItakuBridge.php2
-rw-r--r--bridges/MastodonBridge.php10
-rw-r--r--bridges/PixivBridge.php8
-rw-r--r--caches/SQLiteCache.php4
4 files changed, 19 insertions, 5 deletions
diff --git a/bridges/ItakuBridge.php b/bridges/ItakuBridge.php
index 6b0ebcb2..62a130ff 100644
--- a/bridges/ItakuBridge.php
+++ b/bridges/ItakuBridge.php
@@ -664,7 +664,7 @@ class ItakuBridge extends BridgeAbstract
// Debug::log($url);
if ($getJSON) { //get JSON object
if ($cache) {
- $data = $this->loadCacheValue($url, 86400); // 24 hours
+ $data = $this->loadCacheValue($url);
if (is_null($data)) {
$data = getContents($url, $httpHeaders, $curlOptions) or returnServerError("Could not load $url");
$this->saveCacheValue($url, $data);
diff --git a/bridges/MastodonBridge.php b/bridges/MastodonBridge.php
index 81401be9..54ac55bd 100644
--- a/bridges/MastodonBridge.php
+++ b/bridges/MastodonBridge.php
@@ -100,6 +100,10 @@ class MastodonBridge extends BridgeAbstract
// We fetch the boosted content.
try {
$rtContent = $this->fetchAP($content['object']);
+ if (!$rtContent) {
+ // Sometimes fetchAP returns null. Someone should figure out why. json_decode failure?
+ break;
+ }
$rtUser = $this->loadCacheValue($rtContent['attributedTo']);
if (!isset($rtUser)) {
// We fetch the author, since we cannot always assume the format of the URL.
@@ -277,6 +281,10 @@ class MastodonBridge extends BridgeAbstract
array_push($headers, $sig);
}
}
- return json_decode(getContents($url, $headers), true);
+ try {
+ return Json::decode(getContents($url, $headers));
+ } catch (\JsonException $e) {
+ return null;
+ }
}
}
diff --git a/bridges/PixivBridge.php b/bridges/PixivBridge.php
index 5549c609..c4f5277f 100644
--- a/bridges/PixivBridge.php
+++ b/bridges/PixivBridge.php
@@ -353,10 +353,12 @@ class PixivBridge extends BridgeAbstract
private function getCookie()
{
// checks if cookie is set, if not initialise it with the cookie from the config
- $value = $this->loadCacheValue('cookie', 2678400 /* 30 days + 1 day to let cookie chance to renew */);
+ $value = $this->loadCacheValue('cookie');
if (!isset($value)) {
$value = $this->getOption('cookie');
- $this->saveCacheValue('cookie', $this->getOption('cookie'));
+
+ // 30 days + 1 day to let cookie chance to renew
+ $this->saveCacheValue('cookie', $this->getOption('cookie'), 2678400);
}
return $value;
}
@@ -370,7 +372,7 @@ class PixivBridge extends BridgeAbstract
}
if ($cache) {
- $data = $this->loadCacheValue($url, 86400); // 24 hours
+ $data = $this->loadCacheValue($url);
if (!$data) {
$data = getContents($url, $httpHeaders, $curlOptions, true) or returnServerError("Could not load $url");
$this->saveCacheValue($url, $data);
diff --git a/caches/SQLiteCache.php b/caches/SQLiteCache.php
index beb33e88..09689566 100644
--- a/caches/SQLiteCache.php
+++ b/caches/SQLiteCache.php
@@ -2,6 +2,10 @@
declare(strict_types=1);
+/**
+ * The storage table has a column `updated` which is incorrectly named.
+ * It should have been named `expiration` and the code treats it as an expiration date (in unix timestamp)
+ */
class SQLiteCache implements CacheInterface
{
private \SQLite3 $db;