Voting resets comment count to zero (b9.6)

Register an Account
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 06-17-2007, 11:46 PM
Constant Pligger
 
Join Date: Mar 2006
Posts: 537
I think it must be happening in the store_basic() function - I'm using beta 9.6 code, give or take a couple of SVN versions. Whenever a story is voted on, the comment count is put back to zero, and this happens every time. Does anyone (Ash, I'm looking at you here!) know why its being reset to zero, instead of just being updated with its current value?

Shouldnt the line - $link_comments = $this->comments; - be taking care of the comment count, as long as it is preceded by a read() function?
Reply With Quote
  #2 (permalink)  
Old 06-18-2007, 11:56 PM
Pligg Donor
 
Join Date: May 2007
Posts: 14
Quote:
Originally Posted by Simon View Post
I think it must be happening in the store_basic() function - I'm using beta 9.6 code, give or take a couple of SVN versions. Whenever a story is voted on, the comment count is put back to zero, and this happens every time. Does anyone (Ash, I'm looking at you here!) know why its being reset to zero, instead of just being updated with its current value?

Shouldnt the line - $link_comments = $this->comments; - be taking care of the comment count, as long as it is preceded by a read() function?
Thanks for posting this. I've been looking into this for a while, I think I see what's happening now.

Here's what I suspect is happening:

1) In vote.php, it calls $link->read_basic();

2) If you look at the read_basic() function, it sets a lot of the values, but not the comment count.

if(($link = $db->get_row("SELECT link_author, link_status, link_randkey, link_category, link_date, link_votes, link_karma, link_published_date FROM " . table_links . " WHERE link_id = $id"))) {
$this->author=$link->link_author;
$this->votes=$link->link_votes;
$this->karma=$link->link_karma;
$this->status=$link->link_status;
$this->randkey=$link->link_randkey;
$this->category=$link->link_category;

3) vote.php later calls insert_vote
$link->insert_vote($current_user->user_id, $value);

4) At the end of the insert_vote function, it calls store_basic:
$this->store_basic();

5) It looks like store_basic updates the comment count in the link record, but the link->comments values hadn't been read in read_basic();

$link_comments = $this->comments;
$sql = "UPDATE " . table_links . " set `link_reports`=$link_reports, `link_comments`=$link_comments, link_author=$link_author, link_status='$link_status', link_randkey=$link_randkey, link_category=$link_category, link_modified=NULL, link_date=FROM_UNIXTIME($link_date), link_published_date=FROM_UNIXTIME($link_published_ date), link_votes=$link_votes, link_karma=$link_karma WHERE link_id=$this->id";

If this is indeed the culprit, the simplest solution is probably to add setting the comment count in the read_basic() function.
Reply With Quote
  #3 (permalink)  
Old 06-19-2007, 03:58 AM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,042
Please ban user raquebarshad due to spam!

(Spam of this user used to be above my post)

Last edited by tbones; 06-23-2007 at 03:03 PM.
Reply With Quote
  #4 (permalink)  
Old 06-22-2007, 06:29 AM
Casual Pligger
Pligg Version: 9.5
Pligg Template: yget modified
 
Join Date: Apr 2007
Posts: 43
@dystopia
Quote:
the simplest solution is probably to add setting the comment count in the read_basic() function.
Did your Idea fixed the bug?
Reply With Quote
  #5 (permalink)  
Old 06-22-2007, 08:06 PM
Genghis's Avatar
Casual Pligger
 
Join Date: Mar 2007
Posts: 57
Yes. same question here. Do we just add that value to the read_basic function?
Reply With Quote
  #6 (permalink)  
Old 06-22-2007, 08:52 PM
Constant Pligger
 
Join Date: Mar 2006
Posts: 537
I'll go test it out, thanks for providing a possible solution!

EDIT: good catch, it seems to work! Voted on a story with comments, and the count remained constance once comments were defined in read_basic() - to match with store_basic().

I've also added a similar line for the link_reports field, since it also seems to be updated in store_basic().

Last edited by Simon; 06-22-2007 at 09:00 PM.
Reply With Quote
  #7 (permalink)  
Old 06-22-2007, 09:48 PM
Genghis's Avatar
Casual Pligger
 
Join Date: Mar 2007
Posts: 57
Simon,

could you give us just a quick rundown (1,2,3) of what needs to be done to fix this bug. Thank you!
Reply With Quote
  #8 (permalink)  
Old 06-22-2007, 10:01 PM
Constant Pligger
 
Join Date: Mar 2006
Posts: 537
1.) Open up libs/link.php, and find the function read_basic()
2.) There is a SELECT query, add in 2 more fields (link_comments & link_reports)
3.) Then add in 2 lines below that:

$this->comments=$link->link_comments;
$this->reports=$link->link_reports;

That should mean that all fields that are updated in store_basic() are also defined in read_basic().
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change/configure the voting feature so it would only count and display number gskyjr Questions and Comments 15 09-13-2009 09:15 PM
how do i change the value of voting count crowng Questions and Comments 8 12-14-2008 01:41 PM
9.8.1 upgrade: comment count not showing up nothingman Questions and Comments 2 02-21-2008 11:01 PM
Comment Count Update Simon Questions and Comments 4 06-01-2007 10:45 PM
story comment count daone Questions and Comments 0 03-06-2007 11:11 AM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development