Page 1 of 1

Api Bugs on getCategories

Posted: 29 Apr 2016, 10:36
by scmaruthi
There is a problem where getCategories gives out json of incorrect types for ID.

line 159 of api.php to be changed to

Code: Select all

array_push($cats, array("id" => (int)$line["id"],


also change line 175
from

Code: Select all

"unread" => $unread));

to

Code: Select all

"unread" => $unread,
"order_id"=> $cat_id));

Re: Api Bugs on getCategories

Posted: 29 Apr 2016, 11:36
by fox
please use the normal patch submission process via gitlab, thanks

>line 159 of api.php to be changed to

json is untyped

>also change line 175

the change you propose is really strange, care to elaborate?

also, the line numbers in your post are incorrect, you're using old code

Re: Api Bugs on getCategories

Posted: 30 Apr 2016, 13:36
by scmaruthi
thanks for your reply

json is untyped

but the result of the output would be for a integer 1 is "1" vs 1.
Parsing the json in a typed language would be easier.

the change you propose is really strange, care to elaborate?

explicitly defining order_id allows the resulting Json to correctly be parsed as a list of same objects.
whereas the old code would result result in two object types
1 containing ordinaryCategories {id,title,unread,order_id}
and the other specialCategories{id,title,unread}

the choice of assigning order_id to cat_id is to maintain the uniqueness of the field.
it could very well be order_id = 0. It's just to make the object same as the others above.

also, the line numbers in your post are incorrect, you're using old code

sorry I'm using the one from https://tt-rss.org/gitlab/fox/tt-rss/bl ... es/api.php and thought it's was the latest.

Re: Api Bugs on getCategories

Posted: 30 Apr 2016, 15:02
by fox
alright i see your point, its just that setting order_id to entry id was strange