Fix #1625 failure to preserve comment with children when parent is moved to trash

This commit is contained in:
Kijin Sung 2021-02-22 22:00:41 +09:00
parent 0188bb817b
commit 4fe083b3c7
2 changed files with 13 additions and 13 deletions

View file

@ -593,15 +593,12 @@ class boardController extends board
} }
// generate comment controller object // generate comment controller object
$oCommentController = getController('comment'); $oCommentController = getController('comment');
$updateComment = false;
if($this->module_info->comment_delete_message === 'yes' && $instant_delete != 'Y') if($this->module_info->comment_delete_message === 'yes' && $instant_delete != 'Y')
{ {
$output = $oCommentController->updateCommentByDelete($comment, $this->grant->manager); $output = $oCommentController->updateCommentByDelete($comment, $this->grant->manager);
$updateComment = true;
if($this->module_info->trash_use == 'Y') if($this->module_info->trash_use == 'Y')
{ {
$output = $oCommentController->moveCommentToTrash($comment, $updateComment); $output = $oCommentController->moveCommentToTrash($comment, true);
} }
} }
elseif(starts_with('only_comm', $this->module_info->comment_delete_message) && $instant_delete != 'Y') elseif(starts_with('only_comm', $this->module_info->comment_delete_message) && $instant_delete != 'Y')
@ -610,17 +607,16 @@ class boardController extends board
if(count($childs) > 0) if(count($childs) > 0)
{ {
$output = $oCommentController->updateCommentByDelete($comment, $this->grant->manager); $output = $oCommentController->updateCommentByDelete($comment, $this->grant->manager);
$updateComment = true;
if($this->module_info->trash_use == 'Y') if($this->module_info->trash_use == 'Y')
{ {
$output = $oCommentController->moveCommentToTrash($comment, $updateComment); $output = $oCommentController->moveCommentToTrash($comment, true);
} }
} }
else else
{ {
if($this->module_info->trash_use == 'Y') if($this->module_info->trash_use == 'Y')
{ {
$output = $oCommentController->moveCommentToTrash($comment, $updateComment); $output = $oCommentController->moveCommentToTrash($comment);
} }
else else
{ {
@ -636,7 +632,7 @@ class boardController extends board
{ {
if($this->module_info->trash_use == 'Y') if($this->module_info->trash_use == 'Y')
{ {
$output = $oCommentController->moveCommentToTrash($comment, $this->module_info->comment_delete_message); $output = $oCommentController->moveCommentToTrash($comment);
} }
else else
{ {

View file

@ -1266,7 +1266,15 @@ class commentController extends comment
if($updateComment !== true) if($updateComment !== true)
{ {
$output = executeQuery('comment.deleteComment', $trash_args); $args = new stdClass;
$args->comment_srl = $obj->comment_srl;
$output = executeQuery('comment.deleteComment', $args);
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
$output = executeQuery('comment.deleteCommentList', $args);
if(!$output->toBool()) if(!$output->toBool())
{ {
$oDB->rollback(); $oDB->rollback();
@ -1274,10 +1282,6 @@ class commentController extends comment
} }
} }
$args = new stdClass();
$args->comment_srl = $obj->comment_srl;
$output = executeQuery('comment.deleteCommentList', $args);
// update the number of comments // update the number of comments
$comment_count = CommentModel::getCommentCount($obj->document_srl); $comment_count = CommentModel::getCommentCount($obj->document_srl);