Skip to content

Commit

Permalink
Fixing non int pagination variable server error
Browse files Browse the repository at this point in the history
If a user tries to paginate the blog using a value that is not an integer SilverStripe will throw a server error.

Example. Visiting `blog/?start=10.1` will cause the following server error:

```You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '10.1' at line 8```

This change casts the pagination variable to an int before using it.
  • Loading branch information
3Dgoo authored and robbieaverill committed Feb 19, 2018
1 parent 6929e01 commit f948afe
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion code/model/Blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ public function PaginatedList()
$posts->setPageLength($pageSize);

// Set current page
$start = $this->request->getVar($posts->getPaginationGetVar());
$start = (int)$this->request->getVar($posts->getPaginationGetVar());
$posts->setPageStart($start);

return $posts;
Expand Down

0 comments on commit f948afe

Please sign in to comment.