mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Some bug fixes. (#959)
* Fixes #956. Return 404 for missing objects in GenericEntityApiController.php * Fixes #936 and #943. Include Products that expire today in /stock/volatile and "Expiring soon"-sum on stockoverview * Fixes #881. Remove items of deleted shopping lists. * Fixes #875. Prevent infinite nested recipes. * Review Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
parent
cf9bb87f6e
commit
923e027a4b
@ -50,6 +50,10 @@ class GenericEntityApiController extends BaseApiController
|
||||
}
|
||||
|
||||
$object = $this->getDatabase()->{$args['entity']}($args['objectId']);
|
||||
if ($object == null) {
|
||||
return $this->GenericErrorResponse($response, 'Object not found', 404);
|
||||
}
|
||||
|
||||
$object['userfields'] = $userfields;
|
||||
|
||||
return $this->ApiResponse($response, $object);
|
||||
|
@ -395,6 +395,16 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Object not found",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/GenericErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
27
migrations/0108.sql
Normal file
27
migrations/0108.sql
Normal file
@ -0,0 +1,27 @@
|
||||
DELETE FROM shopping_list
|
||||
WHERE shopping_list_id NOT IN (SELECT id FROM shopping_lists);
|
||||
|
||||
CREATE TRIGGER remove_items_from_deleted_shopping_list AFTER DELETE ON shopping_lists
|
||||
BEGIN
|
||||
DELETE FROM shopping_list WHERE shopping_list_id = OLD.id;
|
||||
END;
|
||||
|
||||
CREATE TRIGGER prevent_infinite_nested_recipes_INS BEFORE INSERT ON recipes_nestings
|
||||
BEGIN
|
||||
SELECT CASE WHEN((
|
||||
SELECT 1
|
||||
FROM recipes_nestings_resolved rnr
|
||||
WHERE NEW.recipe_id = rnr.includes_recipe_id
|
||||
AND NEW.includes_recipe_id = rnr.recipe_id
|
||||
) NOTNULL) THEN RAISE(ABORT, "Recursive nested recipe detected") END;
|
||||
END;
|
||||
|
||||
CREATE TRIGGER prevent_infinite_nested_recipes_UPD BEFORE UPDATE ON recipes_nestings
|
||||
BEGIN
|
||||
SELECT CASE WHEN((
|
||||
SELECT 1
|
||||
FROM recipes_nestings_resolved rnr
|
||||
WHERE NEW.recipe_id = rnr.includes_recipe_id
|
||||
AND NEW.includes_recipe_id = rnr.recipe_id
|
||||
) NOTNULL) THEN RAISE(ABORT, "Recursive nested recipe detected") END;
|
||||
END;
|
@ -95,7 +95,7 @@ class StockService extends BaseService
|
||||
|
||||
if ($excludeExpired)
|
||||
{
|
||||
$currentStock = FindAllObjectsInArrayByPropertyValue($currentStock, 'best_before_date', date('Y-m-d 23:59:59', strtotime('now')), '>');
|
||||
$currentStock = FindAllObjectsInArrayByPropertyValue($currentStock, 'best_before_date', date('Y-m-d 23:59:59', strtotime('-1 days')), '>');
|
||||
}
|
||||
|
||||
return $currentStock;
|
||||
|
Loading…
x
Reference in New Issue
Block a user