From 32fccac21c4ea4cf6ba3abc7c8f18e2d30c708dc Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Fri, 27 Jan 2023 10:18:51 +0100 Subject: [PATCH 1/2] rename fillRecipeFromPostParams() to fillBasicRecipeAttributes() --- Controllers/RecipeController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Controllers/RecipeController.php b/Controllers/RecipeController.php index 48ba988..d4993d8 100644 --- a/Controllers/RecipeController.php +++ b/Controllers/RecipeController.php @@ -51,7 +51,7 @@ final class RecipeController View::show("recipe/edit", array("POST_URI" => "/recipe/create", "RECIPE" => null)); } - private static function fillRecipeFromPostParams($O_recipe, Array $A_postParams) + private static function fillBasicRecipeAttributes($O_recipe, Array $A_postParams) { $O_difficulty = DifficultyModel::getByName(Utils::getOrDie($A_postParams, "recipeDifficulty")); if($O_difficulty === null){ @@ -80,7 +80,7 @@ final class RecipeController $O_recipe = RecipeModel::createEmpty(); // fill basic recipe attribtues - self::fillRecipeFromPostParams($O_recipe, $A_postParams); + self::fillBasicRecipeAttributes($O_recipe, $A_postParams); $O_recipe->insert(); // update img if necessary @@ -124,7 +124,7 @@ final class RecipeController } // fill basic recipe attribtues - self::fillRecipeFromPostParams($O_recipe, $A_postParams); + self::fillBasicRecipeAttributes($O_recipe, $A_postParams); $O_recipe->update(); // update img if necessary From 2125fdeea637cdfd082e10e01180295b21f9a5c6 Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Fri, 27 Jan 2023 10:19:05 +0100 Subject: [PATCH 2/2] Only set recipe author ID when inserting --- Controllers/RecipeController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controllers/RecipeController.php b/Controllers/RecipeController.php index d4993d8..f46c7ad 100644 --- a/Controllers/RecipeController.php +++ b/Controllers/RecipeController.php @@ -62,7 +62,6 @@ final class RecipeController $O_recipe->I_TIME = Utils::intOrDie(Utils::getOrDie($A_postParams, "recipeTime")); $O_recipe->S_DESCR = Utils::getOrDie($A_postParams, "recipeDescription"); $O_recipe->I_DIFFICULTY_ID = $O_difficulty->I_ID; - $O_recipe->I_AUTHOR_ID = $_SESSION["ID"]; $S_instructions = ""; $i = 0; @@ -81,6 +80,7 @@ final class RecipeController // fill basic recipe attribtues self::fillBasicRecipeAttributes($O_recipe, $A_postParams); + $O_recipe->I_AUTHOR_ID = $_SESSION["ID"]; $O_recipe->insert(); // update img if necessary