From cfc27641d3523add6182b40739221fc2dce663b0 Mon Sep 17 00:00:00 2001 From: mMarinetti Date: Thu, 3 Nov 2011 10:39:46 +0000 Subject: [PATCH] // added prestashopexception when id_category is wrong when update/save --- classes/Category.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/classes/Category.php b/classes/Category.php index 8af71f242..700be5261 100644 --- a/classes/Category.php +++ b/classes/Category.php @@ -195,6 +195,8 @@ class CategoryCore extends ObjectModel */ public function update($nullValues = false) { + if ($this->id_parent == $this->id) + throw new PrestashopException('a category cannot be it\'s own parent'); // Update group selection $this->updateGroup($this->groupBox); $this->level_depth = $this->calcLevelDepth(); @@ -425,6 +427,8 @@ class CategoryCore extends ObjectModel */ public function recalculateLevelDepth($id_category) { + if (!is_numeric($id_category)) + throw new PrestashopException('id category is not numeric'); /* Gets all children */ $categories = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT id_category, id_parent, level_depth