Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FeverAPI 32-bit fixes #1964

Merged
merged 2 commits into from
Jul 23, 2018
Merged

FeverAPI 32-bit fixes #1964

merged 2 commits into from
Jul 23, 2018

Conversation

Alkarex
Copy link
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
Member Author

Alkarex commented Jul 21, 2018

@kevinpapst

Copy link
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
$sql .= ' id < :id';
$values[':id'] = $max_id;
$order = ' ORDER BY id DESC';
} else {
} elseif ($since_id !== null) {
Copy link
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
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
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
}
} else if (isset($_REQUEST['with_ids'])) {
$entry_ids = explode(',', $_REQUEST['with_ids']);
} else {
// 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
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
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
javerous pushed a commit to javerous/FreshRSS that referenced this pull request Jan 20, 2020
javerous pushed a commit to javerous/FreshRSS that referenced this pull request Jan 20, 2020
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.

None yet

3 participants