OSDN Git Service

Model::Comments: now 'select' method returns Hash, not Array of Hash
authorhylom <hylom@users.sourceforge.jp>
Sun, 30 Oct 2016 11:55:13 +0000 (20:55 +0900)
committerhylom <hylom@users.sourceforge.jp>
Sun, 30 Oct 2016 11:55:13 +0000 (20:55 +0900)
src/newslash_web/lib/Newslash/Model/Comments.pm

index a8de273..c590b38 100644 (file)
@@ -76,8 +76,11 @@ EOSQL
     if (!$comments) {
         $dbh->disconnect();
         return undef;
-  }
+    }
 
+    if ($query_type eq 'cid') {
+        return $comments->[0];
+    }
     if ($query_type eq 'discussion_id') {
         my $root = $self->build_comment_tree($comments);
     }
@@ -175,6 +178,7 @@ sub create {
     $params->{pid} ||= 0;
     if ($params->{pid}) {
         my $parent = $self->select(cid => $params->{pid});
+
         if (!$parent) {
             $self->set_error("parent comment not exists", 100);
             return;