From 4d00c37af2370ad04fff05a1d6d0e5557dc31ad1 Mon Sep 17 00:00:00 2001 From: matks Date: Thu, 16 Nov 2023 15:48:46 +0100 Subject: [PATCH 1/2] Handle bad deletion page call --- productcomments.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/productcomments.php b/productcomments.php index 74c4406..3d00f26 100644 --- a/productcomments.php +++ b/productcomments.php @@ -207,7 +207,13 @@ protected function _postProcess() $commentRepository->deleteReports($id_product_comment); } elseif (Tools::isSubmit('deleteproductcomments')) { $comment = $commentRepository->find($id_product_comment); - $commentRepository->delete($comment); + + if ($comment === null) { + $this->_html .= $this->displayError($this->trans('The comment cannot be deleted', [], 'Modules.Productcomments.Admin')); + } else { + $commentRepository->delete($comment); + Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', true, [], ['configure' => $this->name])); + } } elseif (Tools::isSubmit('submitEditCriterion')) { $criterion = $criterionRepository->findRelation((int) Tools::getValue('id_product_comment_criterion')); $criterion->setType((int) Tools::getValue('id_product_comment_criterion_type')); From 9ccab004560ff9baaff5eb7ad01157c498e27699 Mon Sep 17 00:00:00 2001 From: Mathieu Ferment Date: Thu, 16 Nov 2023 17:36:06 +0100 Subject: [PATCH 2/2] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Nicolas LÅ“uillet --- productcomments.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/productcomments.php b/productcomments.php index 3d00f26..473f5ed 100644 --- a/productcomments.php +++ b/productcomments.php @@ -208,7 +208,7 @@ protected function _postProcess() } elseif (Tools::isSubmit('deleteproductcomments')) { $comment = $commentRepository->find($id_product_comment); - if ($comment === null) { + if ($comment === null) { $this->_html .= $this->displayError($this->trans('The comment cannot be deleted', [], 'Modules.Productcomments.Admin')); } else { $commentRepository->delete($comment);