mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 17:45:39 +00:00
Optimized filter_var
checks
This commit is contained in:
parent
6263715c53
commit
b6139a6991
@ -585,7 +585,7 @@ class StockApiController extends BaseApiController
|
||||
public function ProductStockEntries(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
$allowSubproductSubstitution = false;
|
||||
if (isset($request->getQueryParams()['include_sub_products']) && filter_var($request->getQueryParams()['include_sub_products'], FILTER_VALIDATE_BOOLEAN))
|
||||
if (isset($request->getQueryParams()['include_sub_products']) && filter_var($request->getQueryParams()['include_sub_products'], FILTER_VALIDATE_BOOLEAN) !== false)
|
||||
{
|
||||
$allowSubproductSubstitution = true;
|
||||
}
|
||||
@ -596,7 +596,7 @@ class StockApiController extends BaseApiController
|
||||
public function ProductStockLocations(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
$allowSubproductSubstitution = false;
|
||||
if (isset($request->getQueryParams()['include_sub_products']) && filter_var($request->getQueryParams()['include_sub_products'], FILTER_VALIDATE_BOOLEAN))
|
||||
if (isset($request->getQueryParams()['include_sub_products']) && filter_var($request->getQueryParams()['include_sub_products'], FILTER_VALIDATE_BOOLEAN) !== false)
|
||||
{
|
||||
$allowSubproductSubstitution = true;
|
||||
}
|
||||
@ -781,7 +781,7 @@ class StockApiController extends BaseApiController
|
||||
|
||||
try
|
||||
{
|
||||
if (!filter_var($args['productIdToKeep'], FILTER_VALIDATE_INT) || !filter_var($args['productIdToRemove'], FILTER_VALIDATE_INT))
|
||||
if (filter_var($args['productIdToKeep'], FILTER_VALIDATE_INT) === false || filter_var($args['productIdToRemove'], FILTER_VALIDATE_INT) === false)
|
||||
{
|
||||
throw new \Exception('Provided {productIdToKeep} or {productIdToRemove} is not a valid integer');
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class SystemApiController extends BaseApiController
|
||||
$params = $request->getQueryParams();
|
||||
if (isset($params['offset']))
|
||||
{
|
||||
if (!filter_var($params['offset'], FILTER_VALIDATE_INT))
|
||||
if (filter_var($params['offset'], FILTER_VALIDATE_INT) === false)
|
||||
{
|
||||
throw new \Exception('Query parameter "offset" is not a valid integer');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user