mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 06:42:42 +01:00
Explicitly cast "limit" (page size) API parameter to int
Summary: Do not throw an exception when the `limit` (page size) Conduit API parameter is a float but explicitly convert to int. As an admin, I am not interested in having invalid user-committed query data trigger an error in the server logs. ``` ERROR 8192: Implicit conversion from float to int loses precision at [/var/www/html/phorge/phorge/src/view/control/AphrontCursorPagerView.php:76] ``` Closes T15810 Test Plan: Call `/conduit/method/maniphest.search/` with a float value for the `limit` field. Check the server logs or DarkConsole. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15810 Differential Revision: https://we.phorge.it/D25614
This commit is contained in:
parent
ec6ba69666
commit
1cc04fb83c
1 changed files with 3 additions and 2 deletions
|
@ -72,8 +72,9 @@ final class AphrontCursorPagerView extends AphrontView {
|
||||||
|
|
||||||
public function sliceResults(array $results) {
|
public function sliceResults(array $results) {
|
||||||
if (count($results) > $this->getPageSize()) {
|
if (count($results) > $this->getPageSize()) {
|
||||||
$offset = ($this->beforeID ? count($results) - $this->getPageSize() : 0);
|
$page_size = (int)$this->getPageSize();
|
||||||
$results = array_slice($results, $offset, $this->getPageSize(), true);
|
$offset = ($this->beforeID ? count($results) - $page_size : 0);
|
||||||
|
$results = array_slice($results, $offset, $page_size, true);
|
||||||
$this->moreResults = true;
|
$this->moreResults = true;
|
||||||
}
|
}
|
||||||
return $results;
|
return $results;
|
||||||
|
|
Loading…
Reference in a new issue