From 3430e21be4c2c338946004704daa3788e5df90ce Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 18 May 2020 19:12:06 +0900 Subject: [PATCH] Fix unnecessary query when there are no polls --- modules/comment/comment.model.php | 8 ++++++-- modules/document/document.model.php | 9 +++++++++ modules/poll/poll.admin.view.php | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/comment/comment.model.php b/modules/comment/comment.model.php index d51890a64..df04759ab 100644 --- a/modules/comment/comment.model.php +++ b/modules/comment/comment.model.php @@ -176,9 +176,13 @@ class commentModel extends comment */ function getComments($comment_srl_list, $columnList = array()) { - if(is_array($comment_srl_list)) + if (!is_array($comment_srl_list)) { - $comment_srls = implode(',', $comment_srl_list); + $comment_srl_list = $comment_srl_list ? explode(',', $comment_srl_list) : array(); + } + if (!count($comment_srl_list)) + { + return array(); } // fetch from a database diff --git a/modules/document/document.model.php b/modules/document/document.model.php index 7380c0dd0..04ce31942 100644 --- a/modules/document/document.model.php +++ b/modules/document/document.model.php @@ -187,6 +187,15 @@ class documentModel extends document */ function getDocuments($document_srls, $is_admin = false, $load_extra_vars = true, $columnList = array()) { + if (!is_array($document_srls)) + { + $document_srls = $document_srls ? explode(',', $document_srls) : array(); + } + if (!count($document_srls)) + { + return array(); + } + $args = new stdClass(); $args->document_srls = $document_srls; $args->list_count = is_array($document_srls) ? count($document_srls) : 1; diff --git a/modules/poll/poll.admin.view.php b/modules/poll/poll.admin.view.php index e65742301..8277a8208 100644 --- a/modules/poll/poll.admin.view.php +++ b/modules/poll/poll.admin.view.php @@ -52,7 +52,7 @@ class pollAdminView extends poll $output = $oPollAdminModel->getPollListWithMember($args); // check poll type. document or comment - if(is_array($output->data)) + if(is_array($output->data) && count($output->data)) { $uploadTargetSrlList = array(); foreach($output->data as $value)