From 80c9623f8fdbbd3ee4eb3df2c1d7e69d12aa464a Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 31 May 2025 13:01:27 +0200 Subject: API fix default category (#7610) fix https://github.com/FreshRSS/FreshRSS/issues/7368 --- p/api/greader.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/p/api/greader.php b/p/api/greader.php index 00bcf10f2..5e9076de7 100644 --- a/p/api/greader.php +++ b/p/api/greader.php @@ -332,7 +332,6 @@ final class GReaderAPI { self::internalServerError(); } header('Content-Type: application/json; charset=UTF-8'); - $salt = FreshRSS_Context::systemConf()->salt; $faviconsUrl = Minz_Url::display('/f.php?', '', true); $faviconsUrl = str_replace('/api/greader.php/reader/api/0/subscription', '', $faviconsUrl); //Security if base_url is not set properly $subscriptions = []; @@ -396,11 +395,15 @@ final class GReaderAPI { } } $c_name = htmlspecialchars($c_name, ENT_COMPAT, 'UTF-8'); - $categoryDAO = FreshRSS_Factory::createCategoryDao(); - $cat = $categoryDAO->searchByName($c_name); - $addCatId = $cat === null ? 0 : $cat->id(); - if ($addCatId === 0) { - $addCatId = $categoryDAO->addCategory(['name' => $c_name]) ?: FreshRSS_CategoryDAO::DEFAULTCATEGORYID; + if (in_array($c_name, ['', 'Uncategorized', _t('gen.short.default_category')], true)) { + $addCatId = FreshRSS_CategoryDAO::DEFAULTCATEGORYID; + } else { + $categoryDAO = FreshRSS_Factory::createCategoryDao(); + $cat = $categoryDAO->searchByName($c_name); + $addCatId = $cat === null ? 0 : $cat->id(); + if ($addCatId === 0) { + $addCatId = $categoryDAO->addCategory(['name' => $c_name]) ?: FreshRSS_CategoryDAO::DEFAULTCATEGORYID; + } } } elseif (str_starts_with($remove, 'user/-/label/')) { $addCatId = FreshRSS_CategoryDAO::DEFAULTCATEGORYID; -- cgit v1.2.3