Skip to content

Commit

Permalink
refactor: loadCacheValue/saveCacheValue (#4205)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvikan authored Aug 8, 2024
1 parent 2acd415 commit f358f1a
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 159 deletions.
2 changes: 1 addition & 1 deletion bridges/BugzillaBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ protected function getUser($user)
}

$cache = $this->loadCacheValue($this->instance . $user);
if (!is_null($cache)) {
if ($cache) {
return $cache;
}

Expand Down
2 changes: 1 addition & 1 deletion bridges/FurAffinityBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ public function getName()
$name = parent::getName();
if ($this->getOption('aCookie') !== null) {
$username = $this->loadCacheValue('username');
if ($username !== null) {
if ($username) {
$name = $username . '\'s ' . parent::getName();
}
}
Expand Down
2 changes: 1 addition & 1 deletion bridges/ItakuBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ private function getData(string $url, bool $cache = false, bool $getJSON = false
if ($getJSON) { //get JSON object
if ($cache) {
$data = $this->loadCacheValue($url);
if (is_null($data)) {
if (!$data) {
$data = getContents($url, $httpHeaders, $curlOptions);
$this->saveCacheValue($url, $data);
}
Expand Down
2 changes: 1 addition & 1 deletion bridges/MastodonBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected function parseStatus($content)
break;
}
$rtUser = $this->loadCacheValue($rtContent['attributedTo']);
if (!isset($rtUser)) {
if (!$rtUser) {
// We fetch the author, since we cannot always assume the format of the URL.
$user = $this->fetchAP($rtContent['attributedTo']);
preg_match('/https?:\/\/([a-z0-9-\.]{0,})\//', $rtContent['attributedTo'], $matches);
Expand Down
2 changes: 1 addition & 1 deletion bridges/PixivBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ private function getCookie()
{
// checks if cookie is set, if not initialise it with the cookie from the config
$value = $this->loadCacheValue('cookie');
if (!isset($value)) {
if (!$value) {
$value = $this->getOption('cookie');

// 30 days + 1 day to let cookie chance to renew
Expand Down
2 changes: 1 addition & 1 deletion bridges/WordPressMadaraBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected function getMangaInfo($url)
{
$url_cache = 'TitleInfo_' . preg_replace('/[^\w]/', '.', rtrim($url, '/'));
$cache = $this->loadCacheValue($url_cache);
if (isset($cache)) {
if ($cache) {
return $cache;
}

Expand Down
Loading

0 comments on commit f358f1a

Please sign in to comment.