From a1e137128a413e3fcbe14aedc3513e36802ddf06 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 23 Jan 2014 11:52:33 +0100 Subject: [PATCH 1/2] remove Iterator for deleting folders --- core/lib/Thelia/Action/Cache.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/lib/Thelia/Action/Cache.php b/core/lib/Thelia/Action/Cache.php index 10a70f2f2..85cedadd8 100644 --- a/core/lib/Thelia/Action/Cache.php +++ b/core/lib/Thelia/Action/Cache.php @@ -39,10 +39,8 @@ class Cache extends BaseAction implements EventSubscriberInterface { $dir = $event->getDir(); - $directoryBrowser = new \DirectoryIterator($dir); - $fs = new Filesystem(); - $fs->remove($directoryBrowser); + $fs->remove($dir); } From 2cee70a2b7f8b78550367decbdba7e09ec9fbce9 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 23 Jan 2014 14:43:05 +0100 Subject: [PATCH 2/2] refactor count loop for having better performance has mentionned in #193 --- core/lib/Thelia/Core/Template/Element/BaseLoop.php | 6 +++++- .../Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php | 4 +--- install/faker.php | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index d08e3a741..bbeb57e45 100644 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -337,7 +337,7 @@ abstract class BaseLoop * @param $pagination * @return LoopResult */ - public function exec(&$pagination) + public function exec(&$pagination, $count = false) { if ($this instanceof PropelSearchLoopInterface) { $searchModelCriteria = $this->buildModelCriteria(); @@ -361,6 +361,10 @@ abstract class BaseLoop } } + if ($count) { + return $results ? count($results) : 0; + } + $loopResult = new LoopResult($results); if (true === $this->countable) { diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php index f7b6fc559..64bce76d3 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php @@ -91,9 +91,7 @@ class TheliaLoop extends AbstractSmartyPlugin $dummy = null; - $loopResults = $loop->exec($dummy); - - return $loopResults->valid() ? $loopResults->getCount() : 0; + return $loop->exec($dummy, true); } /** diff --git a/install/faker.php b/install/faker.php index 53a0e477c..4d2cc3c85 100644 --- a/install/faker.php +++ b/install/faker.php @@ -367,18 +367,18 @@ try { //categories and products $productIdList = array(); $categoryIdList = array(); - for ($i=1; $i<5; $i++) { + for ($i=1; $i<20; $i++) { $category = createCategory($faker, 0, $i, $categoryIdList, $contentIdList); - for ($j=1; $jgetId(), $j, $categoryIdList, $contentIdList); - for ($k=0; $k