From 1f43332a1ddf62850a91a19dfda202b76a2b964d Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 30 Apr 2022 06:57:22 +0000 Subject: [PATCH] Only fetch category when it exists --- src/Content/Item.php | 4 ++++ src/Model/Post/Category.php | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/Content/Item.php b/src/Content/Item.php index 5ebd51c1e..0c60c4e26 100644 --- a/src/Content/Item.php +++ b/src/Content/Item.php @@ -93,6 +93,10 @@ class Item $uid = $item['uid'] ?: $uid; + if (!Post\Category::existsForURIId($item['uri-id'], $uid)) { + return [$categories, $folders]; + } + foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid, Post\Category::CATEGORY) as $savedFolderName) { if (!empty($item['author-link'])) { $url = $item['author-link'] . "?category=" . rawurlencode($savedFolderName); diff --git a/src/Model/Post/Category.php b/src/Model/Post/Category.php index 9d2a359ba..60a33bd74 100644 --- a/src/Model/Post/Category.php +++ b/src/Model/Post/Category.php @@ -111,6 +111,11 @@ class Category return array_column($tags, 'name'); } + public static function existsForURIId(int $uri_id, int $uid) + { + return DBA::exists('post-category', ['uri-id' => $uri_id, 'uid' => $uid]); + } + /** * Generates an array of files or categories of a given uri-id *