Quellcode durchsuchen

[pelican_comment_system] Logs a warning if the parent of a comment can not be found.

Related to #714
Bernhard Scheirle vor 8 Jahren
Ursprung
Commit
b31d127735
1 geänderte Dateien mit 7 neuen und 0 gelöschten Zeilen
  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: