From 773bbd86d61cbea9ebb07f4ec1990c6f6a094523 Mon Sep 17 00:00:00 2001 From: vAugagneur Date: Wed, 3 Oct 2012 09:36:25 +0000 Subject: [PATCH] [-] CORE : fixed bug #PSCFV-4634 - Object::cleanPosition() is no longer call in controller but in Object::delete(); --- classes/AttributeGroup.php | 1 + classes/Carrier.php | 1 + classes/Dispatcher.php | 5 +++-- classes/Product.php | 4 +++- classes/controller/AdminController.php | 4 ---- controllers/admin/AdminTabsController.php | 5 ++++- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/classes/AttributeGroup.php b/classes/AttributeGroup.php index 97c7ddc37..058c4ccf9 100644 --- a/classes/AttributeGroup.php +++ b/classes/AttributeGroup.php @@ -139,6 +139,7 @@ class AttributeGroupCore extends ObjectModel IN (SELECT id_attribute FROM `'._DB_PREFIX_.'attribute` WHERE `id_attribute_group` = '.(int)$this->id.')') === false || Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'attribute` WHERE `id_attribute_group` = '.(int)$this->id) === false) return false; + $this->cleanPositions(); } $return = parent::delete(); if ($return) diff --git a/classes/Carrier.php b/classes/Carrier.php index 7d5fd8be9..c25463890 100644 --- a/classes/Carrier.php +++ b/classes/Carrier.php @@ -202,6 +202,7 @@ class CarrierCore extends ObjectModel { if (!parent::delete()) return false; + $this->cleanPositions(); return (Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'cart_rule_carrier WHERE id_carrier = '.(int)$this->id) && $this->deleteTaxRulesGroup(Shop::getShops(true, null, true))); diff --git a/classes/Dispatcher.php b/classes/Dispatcher.php index 7731aeed3..747aa3946 100644 --- a/classes/Dispatcher.php +++ b/classes/Dispatcher.php @@ -287,6 +287,7 @@ class DispatcherCore case self::FC_ADMIN : $tab = Tab::getInstanceFromClassName($this->controller); $retrocompatibility_admin_tab = null; + if ($tab->module) { if (file_exists(_PS_MODULE_DIR_.$tab->module.'/'.$tab->class_name.'.php')) @@ -636,7 +637,7 @@ class DispatcherCore return $this->controller; $controller = Tools::getValue('controller'); - + if (isset($controller) && is_string($controller) && preg_match('/^([0-9a-z_-]+)\?(.*)=(.*)$/Ui', $controller, $m)) { $controller = $m[1]; @@ -648,7 +649,7 @@ class DispatcherCore if (!Validate::isControllerName($controller)) $controller = false; - + // Use routes ? (for url rewriting) if ($this->use_routes && !$controller) { diff --git a/classes/Product.php b/classes/Product.php index 907206df5..0fb2de462 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -668,7 +668,9 @@ class ProductCore extends ObjectModel // If there are still entries in product_shop, don't remove completly the product if ($this->hasMultishopEntries()) return true; - + + Product::cleanPositions($this->id); + Hook::exec('actionProductDelete', array('product' => $this)); if (!$result || !GroupReduction::deleteProductReduction($this->id) || diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 5814aeaf4..50bb6d82c 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -571,11 +571,7 @@ class AdminControllerCore extends Controller $this->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token; } elseif ($object->delete()) - { - if (method_exists($object, 'cleanPositions')) - $object->cleanPositions(); $this->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token; - } $this->errors[] = Tools::displayError('An error occurred during deletion.'); } } diff --git a/controllers/admin/AdminTabsController.php b/controllers/admin/AdminTabsController.php index a39b35dee..c6ba84aa2 100644 --- a/controllers/admin/AdminTabsController.php +++ b/controllers/admin/AdminTabsController.php @@ -278,8 +278,11 @@ class AdminTabsControllerCore extends AdminController // Temporary add the position depend of the selection of the parent category if (!Tools::isSubmit('id_tab')) // @todo Review $_POST['position'] = Tab::getNbTabs(Tools::getValue('id_parent')); - parent::postProcess(); } + + if (!count($this->errors)) + parent::postProcess(); + } protected function afterImageUpload()