Make 'owner_uid' required for 'Feeds::_get_title()' and 'Feeds::_get_cat_title()'.

This commit is contained in:
wn_ 2025-08-29 12:19:04 +00:00
parent 9aafc7bb8d
commit e5c5a1bf42
6 changed files with 21 additions and 28 deletions

View File

@ -175,7 +175,7 @@ class API extends Handler {
if ($unread || !$unread_only) {
array_push($cats, [
'id' => $cat_id,
'title' => Feeds::_get_cat_title($cat_id),
'title' => Feeds::_get_cat_title($cat_id, $_SESSION['uid']),
'unread' => (int) $unread,
]);
}
@ -574,7 +574,7 @@ class API extends Handler {
$unread = Feeds::_get_counters($i, false, true);
if ($unread || !$unread_only) {
$title = Feeds::_get_title($i);
$title = Feeds::_get_title($i, false, $_SESSION['uid']);
$row = [
'id' => $i,

View File

@ -677,7 +677,7 @@ class Feeds extends Handler_Protected {
</script>
<div class="container">
<h1>Feed Debugger: <?= "$feed_id: " . $this->_get_title($feed_id) ?></h1>
<h1>Feed Debugger: <?= "$feed_id: " . $this->_get_title($feed_id, false, $_SESSION['uid']) ?></h1>
<div class="content">
<form method="post" action="" dojoType="dijit.form.Form">
<?= \Controls\hidden_tag("op", "Feeds") ?>
@ -1178,13 +1178,9 @@ class Feeds extends Handler_Protected {
}
}
static function _get_title(int|string $id, bool $cat = false, ?int $owner_uid = null): string {
// We can't rely on the session existing here due to syndicated feeds
if (!$owner_uid)
$owner_uid = $_SESSION['uid'];
static function _get_title(int|string $id, bool $cat = false, int $owner_uid): string {
if ($cat) {
return self::_get_cat_title($id);
return self::_get_cat_title($id, $owner_uid);
} else if ($id == Feeds::FEED_STARRED) {
return __("Starred articles");
} else if ($id == Feeds::FEED_PUBLISHED) {
@ -1347,11 +1343,7 @@ class Feeds extends Handler_Protected {
return $row["count"] ?? 0;
}
static function _get_cat_title(int $cat_id, ?int $owner_uid = null): string {
// We can't rely on the session existing here due to syndicated feeds
if (!$owner_uid)
$owner_uid = $_SESSION['uid'];
static function _get_cat_title(int $cat_id, int $owner_uid): string {
switch ($cat_id) {
case Feeds::CATEGORY_UNCATEGORIZED:
return __("Uncategorized");
@ -1646,7 +1638,7 @@ class Feeds extends Handler_Protected {
$last_error = $row["last_error"];
$last_updated = $row["last_updated"];
} else {
$feed_title = self::_get_title($feed, $owner_uid);
$feed_title = self::_get_title($feed, false, $owner_uid);
}
}
}

View File

@ -182,7 +182,8 @@ class OPML extends Handler_Protected {
if ($cat_filter && $tmp_line["cat_id"] || $tmp_line["feed_id"]) {
$tmp_line["feed"] = Feeds::_get_title(
$cat_filter ? $tmp_line["cat_id"] : $tmp_line["feed_id"],
$cat_filter);
$cat_filter,
$_SESSION['uid']);
} else {
$tmp_line["feed"] = "";
}
@ -193,13 +194,13 @@ class OPML extends Handler_Protected {
if (str_starts_with($feed_id, "CAT:")) {
$feed_id = (int)substr($feed_id, 4);
if ($feed_id) {
array_push($match, [Feeds::_get_cat_title($feed_id), true, false]);
array_push($match, [Feeds::_get_cat_title($feed_id, $owner_uid), true, false]);
} else {
array_push($match, [0, true, true]);
}
} else {
if ($feed_id) {
array_push($match, [Feeds::_get_title((int)$feed_id), false, false]);
array_push($match, [Feeds::_get_title((int)$feed_id, false, $_SESSION['uid']), false, false]);
} else {
array_push($match, [0, false, true]);
}

View File

@ -1103,7 +1103,7 @@ class Pref_Feeds extends Handler_Protected {
return [
'id' => 'CAT:' . $cat_id,
'items' => array(),
'name' => Feeds::_get_cat_title($cat_id),
'name' => Feeds::_get_cat_title($cat_id, $_SESSION['uid']),
'type' => 'category',
'unread' => -1, //(int) Feeds::_get_cat_unread($cat_id);
'bare_id' => $cat_id,
@ -1115,7 +1115,7 @@ class Pref_Feeds extends Handler_Protected {
*/
private function feedlist_init_feed(int $feed_id, ?string $title = null, bool $unread = false, string $error = '', string $updated = ''): array {
if (!$title)
$title = Feeds::_get_title($feed_id, false);
$title = Feeds::_get_title($feed_id, false, $_SESSION['uid']);
if ($unread === false)
$unread = Feeds::_get_counters($feed_id, false, true);
@ -1284,7 +1284,7 @@ class Pref_Feeds extends Handler_Protected {
]);
print json_encode([
"title" => Feeds::_get_title($feed_id, $is_cat),
"title" => Feeds::_get_title($feed_id, $is_cat, $_SESSION['uid']),
"link" => $link
]);
}

View File

@ -261,10 +261,10 @@ class Pref_Filters extends Handler_Protected {
if (str_starts_with($feed_id, "CAT:")) {
$feed_id = (int)substr($feed_id, 4);
array_push($feeds_fmt, Feeds::_get_cat_title($feed_id));
array_push($feeds_fmt, Feeds::_get_cat_title($feed_id, $_SESSION['uid']));
} else {
if ($feed_id)
array_push($feeds_fmt, Feeds::_get_title((int)$feed_id));
array_push($feeds_fmt, Feeds::_get_title((int)$feed_id, false, $_SESSION['uid']));
else
array_push($feeds_fmt, __("All feeds"));
}
@ -274,9 +274,9 @@ class Pref_Filters extends Handler_Protected {
} else {
$where = $rule->cat_filter ?
Feeds::_get_cat_title($rule->cat_id ?? 0) :
Feeds::_get_cat_title($rule->cat_id ?? 0, $_SESSION['uid']) :
($rule->feed_id ?
Feeds::_get_title($rule->feed_id) : __("All feeds"));
Feeds::_get_title($rule->feed_id, false, $_SESSION['uid']) : __("All feeds"));
}
$inverse_class = $rule->inverse ? "inverse" : "";
@ -460,10 +460,10 @@ class Pref_Filters extends Handler_Protected {
if (str_starts_with($feed_id, "CAT:")) {
$feed_id = (int)substr($feed_id, 4);
array_push($feeds_fmt, Feeds::_get_cat_title($feed_id));
array_push($feeds_fmt, Feeds::_get_cat_title($feed_id, $_SESSION['uid']));
} else {
if ($feed_id)
array_push($feeds_fmt, Feeds::_get_title((int)$feed_id));
array_push($feeds_fmt, Feeds::_get_title((int)$feed_id, false, $_SESSION['uid']));
else
array_push($feeds_fmt, __("All feeds"));
}

View File

@ -210,7 +210,7 @@ class Af_Psql_Trgm extends Plugin {
<li>
<i class='material-icons'>rss_feed</i>
<a href='#' onclick="CommonDialogs.editFeed(<?= $f ?>)">
<?= Feeds::_get_title($f) ?>
<?= Feeds::_get_title($f, false, $_SESSION['uid']) ?>
</a>
</li>
<?php } ?>