Browse Source

Merge pull request #715 from Scheirle/pcs_warning

[pelican_comment_system] Logs a warning if the parent of a comment can not be found.
Justin Mayer 8 years ago
parent
commit
500b05486a
1 changed files with 7 additions and 0 deletions
  1. 7 0
      pelican_comment_system/pelican_comment_system.py

+ 7 - 0
pelican_comment_system/pelican_comment_system.py

@@ -187,9 +187,16 @@ def add_static_comments(gen, content):
 
     # TODO: Fix this O(n²) loop
     for reply in replies:
+        found_parent = False
         for comment in chain(comments, replies):
             if comment.slug == reply.replyto:
                 comment.addReply(reply)
+                found_parent = True
+                break
+        if not found_parent:
+            logger.warning('Comment "%s/%s" is a reply to non-existent comment "%s". '
+                'Make sure the replyto attribute is set correctly.',
+                content.slug, reply.slug, reply.replyto)
 
     count = 0
     for comment in comments: