kareila: (Default)
kareila ([personal profile] kareila) wrote in [site community profile] changelog2009-07-20 03:58 pm

[dw-free] Comment editing still disabled if reply has been deleted

[commit: http://hg.dwscoalition.org/dw-free/rev/c983aaae3857]

http://bugs.dwscoalition.org/show_bug.cgi?id=692

Allow editing if there are no undeleted comments.

Patch by [personal profile] afuna.

Files modified:
  • cgi-bin/LJ/Comment.pm
--------------------------------------------------------------------------------
diff -r f92bdbc5f35a -r c983aaae3857 cgi-bin/LJ/Comment.pm
--- a/cgi-bin/LJ/Comment.pm	Mon Jul 20 15:46:42 2009 +0000
+++ b/cgi-bin/LJ/Comment.pm	Mon Jul 20 10:58:34 2009 -0500
@@ -386,6 +386,11 @@ sub has_children {
     my $self = shift;
 
     return $self->children ? 1 : 0;
+}
+
+sub has_nondeleted_children {
+    my $nondeleted_children = grep { ! $_->is_deleted } $_[0]->children;
+    return $nondeleted_children ? 1 : 0;
 }
 
 # returns true if entry currently exists.  (it's possible for a given
@@ -934,8 +939,8 @@ sub user_can_edit {
         return 0;
     }
 
-    # comment cannot have any replies
-    if ($self->has_children) {
+    # comment cannot have any replies; deleted comments don't count
+    if ($self->has_nondeleted_children) {
         $$errref = LJ::Lang::ml('talk.error.cantedit.haschildren');
         return 0;
     }
--------------------------------------------------------------------------------