Ensured pagination params in visits list are properly parsed to integer

This commit is contained in:
Alejandro Celaya 2018-11-28 20:53:04 +01:00
parent 4d2684be52
commit 1d4ef4e9a4
2 changed files with 9 additions and 2 deletions

View File

@ -92,4 +92,7 @@ WORKDIR /home/shlink
# Expose swoole port
EXPOSE 8080
CMD /usr/local/bin/composer update && ./vendor/bin/zend-expressive-swoole start
CMD /usr/local/bin/composer update && \
# When restarting the container, swoole might think it is already in execution
# This forces the app to be started every second until the exit code is 0
until php ./vendor/bin/zend-expressive-swoole start; do sleep 1 ; done

View File

@ -27,7 +27,11 @@ final class VisitsParams
$startDate = self::getDateQueryParam($query, 'startDate');
$endDate = self::getDateQueryParam($query, 'endDate');
return new self(new DateRange($startDate, $endDate), $query['page'] ?? 1, $query['itemsPerPage'] ?? null);
return new self(
new DateRange($startDate, $endDate),
(int) ($query['page'] ?? 1),
isset($query['itemsPerPage']) ? (int) $query['itemsPerPage'] : null
);
}
private static function getDateQueryParam(array $query, string $key): ?Chronos