aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Dag <me@dvikan.no> 2024-07-31 19:25:51 +0200
committerGravatar GitHub <noreply@github.com> 2024-07-31 19:25:51 +0200
commit8a1f2604aa9358c6f70e078e704e5c674683eaab (patch)
treeef938467bec7a8453761ee11dd29b65706e03287
parentb8a9f34527c15f99cd8566b72d9a9a5c2b9f95a5 (diff)
downloadrss-bridge-8a1f2604aa9358c6f70e078e704e5c674683eaab.tar.gz
rss-bridge-8a1f2604aa9358c6f70e078e704e5c674683eaab.tar.zst
rss-bridge-8a1f2604aa9358c6f70e078e704e5c674683eaab.zip
fix: bug in prior refactor (#4179)
* fix: bug in prior refactor * fix deprecation notice
-rw-r--r--actions/DisplayAction.php19
-rw-r--r--bridges/GelbooruBridge.php18
2 files changed, 17 insertions, 20 deletions
diff --git a/actions/DisplayAction.php b/actions/DisplayAction.php
index 54782edc..93813004 100644
--- a/actions/DisplayAction.php
+++ b/actions/DisplayAction.php
@@ -112,6 +112,15 @@ class DisplayAction implements ActionInterface
$input = array_diff_key($requestArray, array_fill_keys($remove, ''));
$bridge->setInput($input);
$bridge->collectData();
+ $items = $bridge->getItems();
+ if (isset($items[0]) && is_array($items[0])) {
+ $feedItems = [];
+ foreach ($items as $item) {
+ $feedItems[] = FeedItem::fromArray($item);
+ }
+ $items = $feedItems;
+ }
+ $feed = $bridge->getFeed();
} catch (\Exception $e) {
// Probably an exception inside a bridge
if ($e instanceof HttpException) {
@@ -145,16 +154,6 @@ class DisplayAction implements ActionInterface
}
}
- $items = $bridge->getItems();
- if (isset($items[0]) && is_array($items[0])) {
- $feedItems = [];
- foreach ($items as $item) {
- $feedItems[] = FeedItem::fromArray($item);
- }
- $items = $feedItems;
- }
- $feed = $bridge->getFeed();
-
$formatFactory = new FormatFactory();
$format = $formatFactory->create($format);
diff --git a/bridges/GelbooruBridge.php b/bridges/GelbooruBridge.php
index 5fc6b33c..96d16bf9 100644
--- a/bridges/GelbooruBridge.php
+++ b/bridges/GelbooruBridge.php
@@ -33,7 +33,7 @@ class GelbooruBridge extends BridgeAbstract
return $this->getURI()
. 'index.php?&page=dapi&s=post&q=index&json=1&pid=' . $this->getInput('p')
. '&limit=' . $this->getInput('l')
- . '&tags=' . urlencode($this->getInput('t'));
+ . '&tags=' . urlencode($this->getInput('t') ?? '');
}
/*
@@ -76,18 +76,16 @@ class GelbooruBridge extends BridgeAbstract
public function collectData()
{
- $content = getContents($this->getFullURI());
- // $content is empty string
+ $url = $this->getFullURI();
+ $content = getContents($url);
- // Most other Gelbooru-based boorus put their content in the root of
- // the JSON. This check is here for Bridges that inherit from this one
- $posts = json_decode($content);
- if (isset($posts->post)) {
- $posts = $posts->post;
+ if ($content === '') {
+ return;
}
- if (is_null($posts)) {
- returnServerError('No posts found.');
+ $posts = Json::decode($content, false);
+ if (isset($posts->post)) {
+ $posts = $posts->post;
}
foreach ($posts as $post) {