From 567587718b7b4ad1942fd58a683c82a08a250b80 Mon Sep 17 00:00:00 2001 From: onli Date: Tue, 12 Jun 2018 23:49:11 +0200 Subject: [PATCH] React to errors when comment could not be deleted (#527) --- include/admin/comments.inc.php | 8 ++++++-- lang/addlang.txt | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/admin/comments.inc.php b/include/admin/comments.inc.php index f4c75bc7..34c59787 100644 --- a/include/admin/comments.inc.php +++ b/include/admin/comments.inc.php @@ -107,8 +107,12 @@ if (isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminActio /* We are asked to delete a comment */ if (isset($serendipity['GET']['adminAction']) && $serendipity['GET']['adminAction'] == 'delete' && serendipity_checkFormToken()) { - serendipity_deleteComment($serendipity['GET']['id'], $serendipity['GET']['entry_id']); - $msg[] = DONE . ': '. sprintf(COMMENT_DELETED, (int)$serendipity['GET']['id']); + $success = serendipity_deleteComment($serendipity['GET']['id'], $serendipity['GET']['entry_id']); + if ($success === true) { + $msg[] = DONE . ': '. sprintf(COMMENT_DELETED, (int)$serendipity['GET']['id']); + } else { + $errormsg[] = ERROR . ': '. sprintf(COMMENT_NOT_DELETED, (int)$serendipity['GET']['id']); + } } /* We are either in edit mode, or preview mode */ diff --git a/lang/addlang.txt b/lang/addlang.txt index 5e12ef79..56b4e83a 100644 --- a/lang/addlang.txt +++ b/lang/addlang.txt @@ -1,2 +1,3 @@ @define('URL_NOT_FOUND', 'The requested page could not be found (404). This is the default page.'); @define('INSERT_ALL, 'Insert All'); +@define('COMMENT_NOT_DELETED', 'Could not delete comment #%s .'); \ No newline at end of file