Skip to content

FeverAPI 32-bit fixes#1964

Merged
Alkarex merged 2 commits intoFreshRSS:devfrom
Alkarex:feverapi-32bit
Jul 23, 2018
Merged

FeverAPI 32-bit fixes#1964
Alkarex merged 2 commits intoFreshRSS:devfrom
Alkarex:feverapi-32bit

Conversation

@Alkarex
Copy link
Copy Markdown
Member

@Alkarex Alkarex commented Jul 21, 2018

@Alkarex Alkarex added this to the 1.12.0 milestone Jul 21, 2018
@Alkarex Alkarex added the API 🤝 API for other clients label Jul 21, 2018
@Alkarex
Copy link
Copy Markdown
Member Author

Alkarex commented Jul 21, 2018

@kevinpapst

Copy link
Copy Markdown
Member

@Frenzie Frenzie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks straightforward

p/api/fever.php Outdated
$values[':id'] = $max_id;
$order = ' ORDER BY id DESC';
} else {
} elseif ($since_id !== null) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was wrong before, so just the question if we want to make it fail safe:
Looks like the calling part makes sure that either since_id or max_id is not null. But if we consider that someone is trying to use the API programmatically, then we should move both the WHERE and the ORDER (or at least the WHERE) clause into the if-else. Otherwise the SQL would be broken if someone calls this function with max_id=null and since_id=null.
Or probably use an array to collect all WHERE parts and append it with implode(' AND ', $where) before $order is added to $sql.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Here is a suggestion 44d3e51

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old 1=1 trick is also fine :-D

p/api/fever.php Outdated
// use the since_id argument to request the next $item_limit items
$since_id = isset($_REQUEST['since_id']) && is_numeric($_REQUEST['since_id']) ? intval($_REQUEST['since_id']) : 0;
$since_id = '' . $_REQUEST['since_id'];
if (!ctype_digit($since_id) || $since_id < 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I read the docu correct, a negative sign would already not be accepted by ctype_digit as it is a non numeric value. So I guess the <0 check is not required.
Also from the documentation: the string 000000001 would be accepted, but I don't know what the database makes out of it in that case id > 000000001. Thats why I originally used intval().
But to be honest, I didn't test these edge cases.

@kevinpapst
Copy link
Copy Markdown
Contributor

So you pushed while I was still reviewing and typing. LOL, seems you catched my remarks before I even submitted them ;-)
Looks good to me.

@Alkarex Alkarex merged commit 763ceff into FreshRSS:dev Jul 23, 2018
@Alkarex Alkarex deleted the feverapi-32bit branch July 23, 2018 20:50
Alkarex added a commit that referenced this pull request Jul 23, 2018
@Alkarex Alkarex modified the milestones: 1.12.0, 1.11.2 Sep 3, 2018
mdemoss pushed a commit to mdemoss/FreshRSS that referenced this pull request Mar 25, 2021
mdemoss pushed a commit to mdemoss/FreshRSS that referenced this pull request Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API 🤝 API for other clients

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants