@ -442,8 +442,8 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
$out[] = [
'name' => $c['name'],
'id' => "CAT:".$c['id'],
'bare_id' => $c['id'],
'parent_id' => $c['parent'], // top-level categories are not supposed to have this property; we deviated and have the property set to null because it's simpler that way
'bare_id' => (int) $c['id'],
'parent_id' => (int) $c['parent'] ?: null, // top-level categories are not supposed to have this property; we deviated and have the property set to null because it's simpler that way
'type' => "category",
'auxcounter' => 0,
'unread' => 0,
@ -714,13 +714,13 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
// NOTE: the list is a flat one: it includes children, but not other descendents
foreach (Arsse::$db->folderList($user, $cat, false) as $c) {
// get the number of unread for the category and its descendents; those with zero unread are excluded in "unread-only" mode
$count = Arsse::$db->articleCount($user, (new Context)->unread(true)->folder($c['id']));
$count = Arsse::$db->articleCount($user, (new Context)->unread(true)->folder((int) $c['id']));
if (!$unread || $count) {
$out[] = [
'id' => $c['id'],
'title' => $c['name'],
'unread' => $count,
'is_cat' => true,
'id' => (int) $c['id'],
'title' => $c['name'],
'unread' => (int) $count,
'is_cat' => true,
'order_id' => ++$order,
];
}
@ -764,9 +764,9 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
}
// otherwise, append the subscription
$out[] = [
'id' => $s['id'],
'id' => (int) $s['id'],
'title' => $s['title'],
'unread' => $s['unread'],
'unread' => (int) $s['unread'],
'cat_id' => (int) $s['folder'],
'feed_url' => $s['url'],
'has_icon' => (bool) $s['favicon'],
@ -920,8 +920,8 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
return (abs($id) - self::LABEL_OFFSET);
}
protected function labelOut(int $id): int {
return ($id * -1 - self::LABEL_OFFSET);
protected function labelOut($id): int {
return ((int) $id * -1 - self::LABEL_OFFSET);
}
public function opGetLabels(array $data): array {
@ -1194,12 +1194,12 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
return $out;
}
protected function articleLabelList(array $labels, int $id): array {
protected function articleLabelList(array $labels, $id): array {
$out = [];
if (!$labels) {
return $out;
}
foreach (Arsse::$db->articleLabelsGet(Arsse::$user->id, $id) as $label) {
foreach (Arsse::$db->articleLabelsGet(Arsse::$user->id, (int) $id) as $label) {
$out[] = [
$this->labelOut($label), // ID
$labels[$label], // name
@ -1224,7 +1224,7 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
$out = [];
try {
foreach ($this->fetchArticles($data, Database::LIST_MINIMAL) as $row) {
$out[] = ['id' => $row['id']];
$out[] = ['id' => (int) $row['id']];
}
} catch (ExceptionInput $e) {
// ignore database errors (feeds/categories that don't exist)
@ -1246,7 +1246,7 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
try {
foreach ($this->fetchArticles($data, Database::LIST_FULL) as $article) {