Deleting moderated comments

Found a bug? Tell us!!
Post Reply
griffinn
Regular
Posts: 6
Joined: Tue Sep 14, 2004 4:07 pm
Contact:

Deleting moderated comments

Post by griffinn »

Just gave 0.7-beta2 a spin. Thank you for making comment moderation work in PostgreSQL. :)

However, when I delete a comment that's pending approval, the "comments" attribute in serendipity_entries table is decremented as if I'm deleting a published comment. If the entry so far does not have any published comments, this will give a comment count of -1 for the entry.
tomsommer
Core Developer
Posts: 240
Joined: Tue Sep 02, 2003 6:43 pm
Location: Denmark
Contact:

Post by tomsommer »

Nice catch, will look into this ASAP.
Tom Sommer (Serendipity Core Developer)
http://blog.dreamcoder.dk
tomsommer
Core Developer
Posts: 240
Joined: Tue Sep 02, 2003 6:43 pm
Location: Denmark
Contact:

Post by tomsommer »

Should be fixed now, thanks :)
Tom Sommer (Serendipity Core Developer)
http://blog.dreamcoder.dk
griffinn
Regular
Posts: 6
Joined: Tue Sep 14, 2004 4:07 pm
Contact:

Post by griffinn »

Oopsie, it looks like the same problem has crawled back into 0.7-beta3.
griffinn
Regular
Posts: 6
Joined: Tue Sep 14, 2004 4:07 pm
Contact:

Post by griffinn »

The same problem is still in 0.7-rc1.

I've finally gotten my act together to track it down. The glitch is in serendipity_functions.inc.php, and here's the patch.

Code: Select all

--- serendipity_functions.inc.php.good	2004-10-21 22:51:48.000000000 +0800
+++ serendipity_functions.inc.php	2004-10-21 22:52:30.000000000 +0800
@@ -1476,7 +1476,7 @@
         $sql = serendipity_db_query("SELECT status FROM {$serendipity['dbPrefix']}comments
                                             WHERE entry_id = '". (int)$entry_id ."'
                                                     AND id = '". (int)$id ."'
-                                                    $admin");
+                                                    $admin", true);
 
         serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}comments
                                     WHERE entry_id = '". (int)$entry_id ."'
All the patch changes is it sets $single to true explicitly when calling serendipity_db_query() to check the approval status of the comment, so that a simple associated array (not an array of an array) will be returned. (The code that follows expects $sql to be a simple array.)

I've just tried creating and deleting a few unapproved comments in my own blog, and it seems to work fine.
tomsommer
Core Developer
Posts: 240
Joined: Tue Sep 02, 2003 6:43 pm
Location: Denmark
Contact:

Post by tomsommer »

griffinn wrote:The same problem is still in 0.7-rc1.

I've finally gotten my act together to track it down. The glitch is in serendipity_functions.inc.php, and here's the patch.

Code: Select all

--- serendipity_functions.inc.php.good	2004-10-21 22:51:48.000000000 +0800
+++ serendipity_functions.inc.php	2004-10-21 22:52:30.000000000 +0800
@@ -1476,7 +1476,7 @@
         $sql = serendipity_db_query("SELECT status FROM {$serendipity['dbPrefix']}comments
                                             WHERE entry_id = '". (int)$entry_id ."'
                                                     AND id = '". (int)$id ."'
-                                                    $admin");
+                                                    $admin", true);
 
         serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}comments
                                     WHERE entry_id = '". (int)$entry_id ."'
All the patch changes is it sets $single to true explicitly when calling serendipity_db_query() to check the approval status of the comment, so that a simple associated array (not an array of an array) will be returned. (The code that follows expects $sql to be a simple array.)

I've just tried creating and deleting a few unapproved comments in my own blog, and it seems to work fine.
Thanks, committed to CVS
Tom Sommer (Serendipity Core Developer)
http://blog.dreamcoder.dk
Post Reply