From e206312086739934a6751d42f2ebd85697cc6ead Mon Sep 17 00:00:00 2001 From: Philipp Vujic Date: Tue, 12 Mar 2024 12:11:55 +0100 Subject: [PATCH 1/7] Fix Module Cache clear in Multishop context --- src/Core/Module/ModuleRepository.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Core/Module/ModuleRepository.php b/src/Core/Module/ModuleRepository.php index 41b881668fd6f..aa7994f0fd64e 100644 --- a/src/Core/Module/ModuleRepository.php +++ b/src/Core/Module/ModuleRepository.php @@ -202,13 +202,11 @@ public function clearCache(?string $moduleName = null, bool $allShops = false): { $this->installedModules = null; if ($moduleName !== null) { + $cacheKey = $this->getCacheKey($moduleName); if ($allShops) { - foreach (Shop::getShops(true, null, true) as $shopId) { - $cacheKey = $this->getCacheKey($moduleName, $shopId); - if ($this->cacheProvider->contains($cacheKey)) { - if (!$this->cacheProvider->delete($cacheKey)) { - return false; - } + if ($this->cacheProvider->contains($cacheKey)) { + if (!$this->cacheProvider->delete($cacheKey)) { + return false; } } From ea262bc423c6ffa7359fa5e3dbe64fa96ea0b113 Mon Sep 17 00:00:00 2001 From: Philipp Vujic Date: Tue, 12 Mar 2024 12:14:07 +0100 Subject: [PATCH 2/7] Removed duplicated variable --- src/Core/Module/ModuleRepository.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Core/Module/ModuleRepository.php b/src/Core/Module/ModuleRepository.php index aa7994f0fd64e..06b649674799f 100644 --- a/src/Core/Module/ModuleRepository.php +++ b/src/Core/Module/ModuleRepository.php @@ -212,7 +212,6 @@ public function clearCache(?string $moduleName = null, bool $allShops = false): return true; } else { - $cacheKey = $this->getCacheKey($moduleName); if ($this->cacheProvider->contains($cacheKey)) { return $this->cacheProvider->delete($cacheKey); } From 62a7f2c5cbca7f2dbdfc662c4980ab03959a6709 Mon Sep 17 00:00:00 2001 From: Philipp Vujic Date: Thu, 14 Mar 2024 10:43:18 +0100 Subject: [PATCH 3/7] Fix: Clear all cache if all shops --- src/Core/Module/ModuleRepository.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Core/Module/ModuleRepository.php b/src/Core/Module/ModuleRepository.php index 06b649674799f..3aa43973cb6ae 100644 --- a/src/Core/Module/ModuleRepository.php +++ b/src/Core/Module/ModuleRepository.php @@ -202,19 +202,20 @@ public function clearCache(?string $moduleName = null, bool $allShops = false): { $this->installedModules = null; if ($moduleName !== null) { - $cacheKey = $this->getCacheKey($moduleName); if ($allShops) { - if ($this->cacheProvider->contains($cacheKey)) { - if (!$this->cacheProvider->delete($cacheKey)) { - return false; + foreach (Shop::getShops(true, null, true) as $shopId) { + $cacheKey = $this->getCacheKey($moduleName, $shopId); + if ($this->cacheProvider->contains($cacheKey)) { + if (!$this->cacheProvider->delete($cacheKey)) { + return false; + } } } + } - return true; - } else { - if ($this->cacheProvider->contains($cacheKey)) { - return $this->cacheProvider->delete($cacheKey); - } + $cacheKey = $this->getCacheKey($moduleName); + if ($this->cacheProvider->contains($cacheKey)) { + return $this->cacheProvider->delete($cacheKey); } } From 2cea4bea844bf91e5164be6f7d0d05ba153345d5 Mon Sep 17 00:00:00 2001 From: Hlavtox Date: Wed, 20 Mar 2024 18:22:21 +0100 Subject: [PATCH 4/7] Make updating order status stronger --- .../Order/CommandHandler/UpdateOrderStatusHandler.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Adapter/Order/CommandHandler/UpdateOrderStatusHandler.php b/src/Adapter/Order/CommandHandler/UpdateOrderStatusHandler.php index e6210ed04087b..a375af1e305bc 100644 --- a/src/Adapter/Order/CommandHandler/UpdateOrderStatusHandler.php +++ b/src/Adapter/Order/CommandHandler/UpdateOrderStatusHandler.php @@ -51,9 +51,12 @@ public function handle(UpdateOrderStatusCommand $command) $order = $this->getOrder($command->getOrderId()); $orderState = $this->getOrderStateObject($command->getNewOrderStatusId()); + /* + * Try to load current order status. There may be cases when there is none, for example when something happens + * during order creation process. That's why we check for $currentOrderState validity. + */ $currentOrderState = $order->getCurrentOrderState(); - - if ($currentOrderState->id == $orderState->id) { + if (!empty($currentOrderState) && $currentOrderState->id == $orderState->id) { throw new OrderException('The order has already been assigned this status.'); } @@ -69,10 +72,10 @@ public function handle(UpdateOrderStatusCommand $command) $history->changeIdOrderState((int) $orderState->id, $order, $useExistingPayments); - $carrier = new Carrier($order->id_carrier, (int) $order->getAssociatedLanguage()->getId()); $templateVars = []; if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') && $order->getShippingNumber()) { + $carrier = new Carrier($order->id_carrier, (int) $order->getAssociatedLanguage()->getId()); $templateVars = [ '{followup}' => str_replace('@', $order->getShippingNumber(), $carrier->url), ]; From 49288bb3bd272866d6ac5765c525dbfed69af3fe Mon Sep 17 00:00:00 2001 From: Morgan Pichat Date: Wed, 20 Mar 2024 17:30:54 +0100 Subject: [PATCH 5/7] Fix PATCH METHOD --- admin-dev/index.php | 2 +- .../new-theme/js/pages/product/service/image.ts | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/admin-dev/index.php b/admin-dev/index.php index 6194120486a43..981205a55da5f 100644 --- a/admin-dev/index.php +++ b/admin-dev/index.php @@ -73,7 +73,7 @@ $kernel = new AppKernel(_PS_ENV_, _PS_MODE_DEV_); // When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter -//Request::enableHttpMethodParameterOverride(); +Request::enableHttpMethodParameterOverride(); $request = Request::createFromGlobals(); Request::setTrustedProxies([], Request::HEADER_X_FORWARDED_ALL); diff --git a/admin-dev/themes/new-theme/js/pages/product/service/image.ts b/admin-dev/themes/new-theme/js/pages/product/service/image.ts index d2443fd806ea8..bf15c29985669 100644 --- a/admin-dev/themes/new-theme/js/pages/product/service/image.ts +++ b/admin-dev/themes/new-theme/js/pages/product/service/image.ts @@ -73,8 +73,11 @@ export const saveImageInformations = async ( data[`${formName}[apply_to_all_stores]`] = selectedFile.applyToAllStores; return $.ajax(saveUrl, { - method: 'PATCH', - data, + method: 'POST', + data: { + ...data, + _method: 'PATCH', + }, }); }; @@ -113,8 +116,11 @@ export const saveImagePosition = async ( data[`${formName}[shop_id]`] = shopId || 0; return $.ajax(sortUrl, { - method: 'PATCH', - data, + method: 'POST', + data: { + ...data, + _method: 'PATCH', + }, }); }; From 328f637240f80bf8efcb6c8252db4c45d908b355 Mon Sep 17 00:00:00 2001 From: Hlavtox Date: Sun, 24 Mar 2024 13:52:31 +0100 Subject: [PATCH 6/7] Remove usage of deprecated andSelf --- themes/_core/js/checkout-steps.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/_core/js/checkout-steps.js b/themes/_core/js/checkout-steps.js index 32cc38b8718ff..ed673bd381baa 100644 --- a/themes/_core/js/checkout-steps.js +++ b/themes/_core/js/checkout-steps.js @@ -33,7 +33,7 @@ export default class Steps { this.$steps = $(prestashop.selectors.checkout.step); this.$steps.off('click'); - this.$clickableSteps = $(currentStepSelector).prevAll().andSelf(); + this.$clickableSteps = $(currentStepSelector).prevAll().addBack(); this.$clickableSteps.addClass('-clickable'); } From d14fa556036f8296f7ebda927aa2480284fe812e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hlav=C3=A1=C4=8Dek?= Date: Mon, 25 Mar 2024 10:00:36 +0100 Subject: [PATCH 7/7] Update smarty.config.inc.php --- config/smarty.config.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/config/smarty.config.inc.php b/config/smarty.config.inc.php index bcba3c6c10505..b30d21fa963ba 100644 --- a/config/smarty.config.inc.php +++ b/config/smarty.config.inc.php @@ -98,6 +98,7 @@ function smartyEscape($string, $esc_type = 'html', $char_set = null, $double_enc // Native PHP functions smartyRegisterFunction($smarty, 'modifier', 'addcslashes', 'addcslashes'); smartyRegisterFunction($smarty, 'modifier', 'addslashes', 'addslashes'); +smartyRegisterFunction($smarty, 'modifier', 'array_slice', 'array_slice'); smartyRegisterFunction($smarty, 'modifier', 'date', 'date'); smartyRegisterFunction($smarty, 'modifier', 'explode', 'explode'); smartyRegisterFunction($smarty, 'modifier', 'floatval', 'floatval');