From 5197afb87d31ade9d86b033176752d6c7d3d3f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Je=CC=81ro=CC=82me=20Billiras?= Date: Wed, 23 Apr 2014 16:33:01 +0200 Subject: [PATCH 1/3] Load modules by position --- core/lib/Thelia/Model/ModuleQuery.php | 1 + local/config/schema.xml | 3 +++ setup/thelia.sql | 3 ++- setup/update/2.0.1.sql | 12 ++++++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 setup/update/2.0.1.sql diff --git a/core/lib/Thelia/Model/ModuleQuery.php b/core/lib/Thelia/Model/ModuleQuery.php index dfe9b1b3c..c1f9394dd 100644 --- a/core/lib/Thelia/Model/ModuleQuery.php +++ b/core/lib/Thelia/Model/ModuleQuery.php @@ -25,6 +25,7 @@ class ModuleQuery extends BaseModuleQuery if (null === self::$activated) { self::$activated = self::create() ->filterByActivate(1) + ->orderByPosition() ->find(); } diff --git a/local/config/schema.xml b/local/config/schema.xml index 52a0b4319..76691e422 100644 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -728,6 +728,9 @@ + + + diff --git a/setup/thelia.sql b/setup/thelia.sql index 71c5c0e48..02177f0f1 100644 --- a/setup/thelia.sql +++ b/setup/thelia.sql @@ -866,7 +866,8 @@ CREATE TABLE `module` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - UNIQUE INDEX `code_UNIQUE` (`code`) + UNIQUE INDEX `code_UNIQUE` (`code`), + INDEX `idx_module_position` (`position`) ) ENGINE=InnoDB CHARACTER SET='utf8'; -- --------------------------------------------------------------------- diff --git a/setup/update/2.0.1.sql b/setup/update/2.0.1.sql new file mode 100644 index 000000000..8e3192226 --- /dev/null +++ b/setup/update/2.0.1.sql @@ -0,0 +1,12 @@ +# This is a fix for InnoDB in MySQL >= 4.1.x +# It "suspends judgement" for fkey relationships until are tables are set. +SET FOREIGN_KEY_CHECKS = 0; + +UPDATE `config` SET `value`='2.0.1' WHERE `name`='thelia_version'; +UPDATE `config` SET `value`='' WHERE `name`='thelia_extra_version'; + + +ALTER TABLE `module` ADD INDEX `idx_module_position` (`position`); + + +SET FOREIGN_KEY_CHECKS = 1; From 87ae693c018c0b7d08766bac6930513619845637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Je=CC=81ro=CC=82me=20Billiras?= Date: Wed, 23 Apr 2014 16:48:38 +0200 Subject: [PATCH 2/3] Clear current environment caches on modules position update --- core/lib/Thelia/Action/BaseAction.php | 2 +- core/lib/Thelia/Action/Module.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Action/BaseAction.php b/core/lib/Thelia/Action/BaseAction.php index bd37119d6..ed42f14e1 100644 --- a/core/lib/Thelia/Action/BaseAction.php +++ b/core/lib/Thelia/Action/BaseAction.php @@ -27,7 +27,7 @@ class BaseAction * @param ModelCriteria $query * @param UpdatePositionEvent $event * - * @return mixed + * @return null */ protected function genericUpdatePosition(ModelCriteria $query, UpdatePositionEvent $event) { diff --git a/core/lib/Thelia/Action/Module.php b/core/lib/Thelia/Action/Module.php index 6cec76fe7..0c11e5423 100644 --- a/core/lib/Thelia/Action/Module.php +++ b/core/lib/Thelia/Action/Module.php @@ -180,6 +180,8 @@ class Module extends BaseAction implements EventSubscriberInterface public function updatePosition(UpdatePositionEvent $event) { $this->genericUpdatePosition(ModuleQuery::create(), $event); + + $this->cacheClear($event->getDispatcher()); } protected function cacheClear(EventDispatcherInterface $dispatcher) From be923d8f56784fca22920f374e183b6f70a081bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Je=CC=81ro=CC=82me=20Billiras?= Date: Thu, 24 Apr 2014 10:28:59 +0200 Subject: [PATCH 3/3] Change index from position to activate following issue comment [https://github.com/thelia/thelia/pull/332#issuecomment-41174056] --- local/config/schema.xml | 4 ++-- setup/thelia.sql | 2 +- setup/update/2.0.1.sql | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/local/config/schema.xml b/local/config/schema.xml index 76691e422..5607438d1 100644 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -728,8 +728,8 @@ - - + + diff --git a/setup/thelia.sql b/setup/thelia.sql index 02177f0f1..3ff2547b0 100644 --- a/setup/thelia.sql +++ b/setup/thelia.sql @@ -867,7 +867,7 @@ CREATE TABLE `module` `updated_at` DATETIME, PRIMARY KEY (`id`), UNIQUE INDEX `code_UNIQUE` (`code`), - INDEX `idx_module_position` (`position`) + INDEX `idx_module_activate` (`activate`) ) ENGINE=InnoDB CHARACTER SET='utf8'; -- --------------------------------------------------------------------- diff --git a/setup/update/2.0.1.sql b/setup/update/2.0.1.sql index 8e3192226..093ba7510 100644 --- a/setup/update/2.0.1.sql +++ b/setup/update/2.0.1.sql @@ -6,7 +6,7 @@ UPDATE `config` SET `value`='2.0.1' WHERE `name`='thelia_version'; UPDATE `config` SET `value`='' WHERE `name`='thelia_extra_version'; -ALTER TABLE `module` ADD INDEX `idx_module_position` (`position`); +ALTER TABLE `module` ADD INDEX `idx_module_activate` (`activate`); SET FOREIGN_KEY_CHECKS = 1;