From 08fc4d72d97f83d214609ea2d4fc58ffcef7a59b Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 13 Aug 2025 21:15:11 +0900 Subject: [PATCH] Fix incorrect error message when a document/comment is voted/blamed already #2590 --- modules/comment/comment.controller.php | 24 +++++++++++++++---- .../queries/getCommentVotedLogInfo.xml | 1 + modules/document/document.controller.php | 24 +++++++++++++++---- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/modules/comment/comment.controller.php b/modules/comment/comment.controller.php index 3eb2baee8..45cc35706 100644 --- a/modules/comment/comment.controller.php +++ b/modules/comment/comment.controller.php @@ -1606,9 +1606,16 @@ class CommentController extends Comment } // invalid vote if vote info exists in the session info. - if(!empty($_SESSION['voted_comment'][$comment_srl])) + if (!empty($_SESSION['voted_comment'][$comment_srl])) { - return new BaseObject(-1, $failed_voted . '_already'); + if ($_SESSION['voted_comment'][$comment_srl] > 0) + { + return new BaseObject(-1, 'failed_voted_already'); + } + else + { + return new BaseObject(-1, 'failed_blamed_already'); + } } // Get the original comment @@ -1649,10 +1656,17 @@ class CommentController extends Comment $output = executeQuery('comment.getCommentVotedLogInfo', $args); // Pass after registering a session if log information has vote-up logs - if($output->data->count) + if ($output->data->count) { - $_SESSION['voted_comment'][$comment_srl] = false; - return new BaseObject(-1, $failed_voted); + $_SESSION['voted_comment'][$comment_srl] = intval($output->data->point); + if ($output->data->point > 0) + { + return new BaseObject(-1, 'failed_voted_already'); + } + else + { + return new BaseObject(-1, 'failed_blamed_already'); + } } // Call a trigger (before) diff --git a/modules/comment/queries/getCommentVotedLogInfo.xml b/modules/comment/queries/getCommentVotedLogInfo.xml index 6bb3cd9c7..4ab7ec8d2 100644 --- a/modules/comment/queries/getCommentVotedLogInfo.xml +++ b/modules/comment/queries/getCommentVotedLogInfo.xml @@ -4,6 +4,7 @@ + diff --git a/modules/document/document.controller.php b/modules/document/document.controller.php index b4d64844d..d74235425 100644 --- a/modules/document/document.controller.php +++ b/modules/document/document.controller.php @@ -2027,9 +2027,16 @@ class DocumentController extends Document } // Return fail if session already has information about votes - if(!empty($_SESSION['voted_document'][$document_srl])) + if (!empty($_SESSION['voted_document'][$document_srl])) { - return new BaseObject(-1, $failed_voted . '_already'); + if ($_SESSION['voted_document'][$document_srl] > 0) + { + return new BaseObject(-1, 'failed_voted_already'); + } + else + { + return new BaseObject(-1, 'failed_blamed_already'); + } } // Get the original document @@ -2070,10 +2077,17 @@ class DocumentController extends Document $output = executeQuery('document.getDocumentVotedLogInfo', $args); // Pass after registering a session if log information has vote-up logs - if($output->data->count) + if ($output->data->count) { - $_SESSION['voted_document'][$document_srl] = false; - return new BaseObject(-1, $failed_voted); + $_SESSION['voted_document'][$document_srl] = intval($output->data->point); + if ($output->data->point > 0) + { + return new BaseObject(-1, 'failed_voted_already'); + } + else + { + return new BaseObject(-1, 'failed_blamed_already'); + } } // Call a trigger (before)