From 4ab5578ba1cd3dc6dfae0ec5449095f8db9395f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hlav=C3=A1=C4=8Dek?= Date: Wed, 7 Feb 2024 09:26:17 +0100 Subject: [PATCH 1/3] Remove ajaxDie --- controllers/admin/AdminGanalyticsAjax.php | 4 ++-- controllers/front/ajax.php | 4 ++-- tests/phpstan/phpstan-1.7.7.neon | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/controllers/admin/AdminGanalyticsAjax.php b/controllers/admin/AdminGanalyticsAjax.php index 2deb985..012d087 100644 --- a/controllers/admin/AdminGanalyticsAjax.php +++ b/controllers/admin/AdminGanalyticsAjax.php @@ -31,9 +31,9 @@ public function init() if (Validate::isLoadedObject($order) && (isset($this->context->employee->id) && $this->context->employee->id)) { (new GanalyticsRepository())->markOrderAsSent((int) $orderId); - $this->ajaxDie('OK'); + $this->ajaxRender('OK'); } - $this->ajaxDie('KO'); + $this->ajaxRender('KO'); } } diff --git a/controllers/front/ajax.php b/controllers/front/ajax.php index 4c104e5..166a1f5 100644 --- a/controllers/front/ajax.php +++ b/controllers/front/ajax.php @@ -35,11 +35,11 @@ public function initContent() $order = new Order($orderId); if (!Validate::isLoadedObject($order) || $order->id_customer != (int) Tools::getValue('customer')) { - $this->ajaxDie('KO'); + $this->ajaxRender('KO'); } (new GanalyticsRepository())->markOrderAsSent((int) $orderId); - $this->ajaxDie('OK'); + $this->ajaxRender('OK'); } } diff --git a/tests/phpstan/phpstan-1.7.7.neon b/tests/phpstan/phpstan-1.7.7.neon index 364a960..caca568 100644 --- a/tests/phpstan/phpstan-1.7.7.neon +++ b/tests/phpstan/phpstan-1.7.7.neon @@ -6,3 +6,4 @@ parameters: - '#PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler::uninstallModule\(\) calls parent::uninstall\(\) but PrestaShop\\Module\\Ps_Googleanalytics\\Handler\\ModuleHandler does not extend any class.#' - '#Access to an undefined property Cookie\:\:\$ga_admin_order.#' - '#Access to an undefined property Cookie\:\:\$ga_admin_refund.#' + - '#Parameter \#1 \$value of method ControllerCore::ajaxRender\(\) expects null, string given.#' From 548aad0b43dd47638c57d59d57bda88fc96e7677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hlav=C3=A1=C4=8Dek?= Date: Wed, 7 Feb 2024 15:20:10 +0100 Subject: [PATCH 2/3] Add exit command --- controllers/admin/AdminGanalyticsAjax.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/controllers/admin/AdminGanalyticsAjax.php b/controllers/admin/AdminGanalyticsAjax.php index 012d087..1ec6dbc 100644 --- a/controllers/admin/AdminGanalyticsAjax.php +++ b/controllers/admin/AdminGanalyticsAjax.php @@ -32,8 +32,10 @@ public function init() if (Validate::isLoadedObject($order) && (isset($this->context->employee->id) && $this->context->employee->id)) { (new GanalyticsRepository())->markOrderAsSent((int) $orderId); $this->ajaxRender('OK'); + exit; } $this->ajaxRender('KO'); + exit; } } From 08a413201e9b7b8573abfcd004902288b330d354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hlav=C3=A1=C4=8Dek?= Date: Wed, 7 Feb 2024 15:20:33 +0100 Subject: [PATCH 3/3] Update ajax.php --- controllers/front/ajax.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/controllers/front/ajax.php b/controllers/front/ajax.php index 166a1f5..c77698e 100644 --- a/controllers/front/ajax.php +++ b/controllers/front/ajax.php @@ -36,10 +36,12 @@ public function initContent() if (!Validate::isLoadedObject($order) || $order->id_customer != (int) Tools::getValue('customer')) { $this->ajaxRender('KO'); + exit; } (new GanalyticsRepository())->markOrderAsSent((int) $orderId); $this->ajaxRender('OK'); + exit; } }