diff --git a/controllers/front/ReportComment.php b/controllers/front/ReportComment.php index 7183bb76..9be0af98 100644 --- a/controllers/front/ReportComment.php +++ b/controllers/front/ReportComment.php @@ -47,9 +47,7 @@ public function display() return false; } - $content = trim(file_get_contents('php://input')); - $decoded = json_decode($content, true); - $id_product_comment = (int) $decoded['id_product_comment']; + $id_product_comment = (int) Tools::getValue('id_product_comment'); /** @var EntityManagerInterface $entityManager */ $entityManager = $this->container->get('doctrine.orm.entity_manager'); diff --git a/controllers/front/UpdateCommentUsefulness.php b/controllers/front/UpdateCommentUsefulness.php index 60fdf02d..774435b9 100644 --- a/controllers/front/UpdateCommentUsefulness.php +++ b/controllers/front/UpdateCommentUsefulness.php @@ -70,10 +70,8 @@ public function display() return false; } - $content = trim(file_get_contents('php://input')); - $decoded = json_decode($content, true); - $id_product_comment = (int) $decoded['id_product_comment']; - $usefulness = (bool) $decoded['usefulness']; + $id_product_comment = (int) Tools::getValue('id_product_comment'); + $usefulness = (bool) Tools::getValue('usefulness'); /** @var EntityManagerInterface $entityManager */ $entityManager = $this->container->get('doctrine.orm.entity_manager'); diff --git a/views/js/list-comments.js b/views/js/list-comments.js index ec591b59..06de9d5c 100644 --- a/views/js/list-comments.js +++ b/views/js/list-comments.js @@ -185,9 +185,9 @@ jQuery(document).ready(function () { const response = await fetch(updateCommentUsefulnessUrl, { method: "POST", headers: { - "Content-Type": "application/json", + "Content-Type": "application/x-www-form-urlencoded", }, - body: JSON.stringify({id_product_comment: commentId, usefulness: usefulness}), + body: "id_product_comment=" + commentId + "&usefulness=" + usefulness, }); if (response.status === 200) { @@ -222,9 +222,9 @@ jQuery(document).ready(function () { const response = await fetch(reportCommentUrl, { method: "POST", headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({id_product_comment: commentId}), + "Content-Type": "application/x-www-form-urlencoded", + }, + body: "id_product_comment=" + commentId, }); if (response.status === 200) {