Mihir-thakkar has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/332723 )

Change subject: Fix for delete comment bug
......................................................................

Fix for delete comment bug

A reply comment can be deleted by a user with appropriate access. But deleting 
a parent comment should not delete the entire thread which may contain several 
reply comments. So let us replace parent comment text with generic text like 
"This comment is deleted".

Bug: T147272
Change-Id: I82be238633e2cbf033e1e7d658ec5a335195d4b5
---
M CommentClass.php
1 file changed, 27 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Comments 
refs/changes/23/332723/1

diff --git a/CommentClass.php b/CommentClass.php
index c809f09..6ca1b13 100644
--- a/CommentClass.php
+++ b/CommentClass.php
@@ -447,17 +447,34 @@
         * Deletes entries from Comments and Comments_Vote tables and clears 
caches
         */
        function delete() {
+               $commentDate = date( 'Y-m-d H:i:s' );
+
                $dbw = wfGetDB( DB_MASTER );
-               $dbw->delete(
-                       'Comments',
-                       array( 'CommentID' => $this->id ),
-                       __METHOD__
-               );
-               $dbw->delete(
-                       'Comments_Vote',
-                       array( 'Comment_Vote_ID' => $this->id ),
-                       __METHOD__
-               );
+               if ( $this->parentID == 0 ) {
+                       // Replace text of parent comment with "This comment is 
deleted"
+                       $dbw->update(
+                               'Comments',
+                               array(
+                                       'Comment_Username' => "Anonymous",      
+                                       'Comment_Text' => "This comment is 
deleted",
+                                       'Comment_Parent_ID' => $parentID,
+                               ),
+                               array( 'CommentID' => $this->id ),
+                               __METHOD__
+                       );
+               } else {
+                       // Delete the child comment
+                       $dbw->delete(
+                               'Comments',
+                               array( 'CommentID' => $this->id ),
+                               __METHOD__
+                       );
+                       $dbw->delete(
+                               'Comments_Vote',
+                               array( 'Comment_Vote_ID' => $this->id ),
+                               __METHOD__
+                       );      
+               }
                $dbw->commit( __METHOD__ );
 
                // Log the deletion to Special:Log/comments.

-- 
To view, visit https://gerrit.wikimedia.org/r/332723
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I82be238633e2cbf033e1e7d658ec5a335195d4b5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Comments
Gerrit-Branch: master
Gerrit-Owner: Mihir-thakkar <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to