Skip to content

Commit

Permalink
Merge pull request #190 from matks/fix-bad-delete
Browse files Browse the repository at this point in the history
If user mistakenly attempts to delete a comment, fail gracefully
  • Loading branch information
leemyongpakvn authored Nov 17, 2023
2 parents fae55dc + 9ccab00 commit 96bc83c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion productcomments.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down

0 comments on commit 96bc83c

Please sign in to comment.