Go Back   Pligg CMS Forum > Pligg Development > Bug Report

Reply
 
LinkBack (1) Thread Tools Display Modes
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 06-17-2007, 10:46 PM
Constant Pligger
 
Join Date: Mar 2006
Posts: 575
Thanks: 14
Thanked 126 Times in 61 Posts
Voting resets comment count to zero (b9.6)

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, 10:56 PM
Pligg Donor
 
Join Date: May 2007
Posts: 14
Thanks: 0
Thanked 3 Times in 2 Posts
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.
__________________
RankCommercials
Reply With Quote
The Following 2 Users Say Thank You to dystopia For This Useful Post:
  #3 (permalink)  
Old 06-19-2007, 02:58 AM
Constant Pligger
 
Join Date: Apr 2007
Posts: 1,071
Thanks: 53
Thanked 25 Times in 23 Posts
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 02:03 PM..
Reply With Quote
  #4 (permalink)  
Old 06-22-2007, 05:29 AM
Casual Pligger
Pligg Version: 9.5
Pligg Template: yget modified
 
Join Date: Apr 2007
Posts: 43
Thanks: 11
Thanked 1 Time in 1 Post
@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, 07:06 PM
Genghis's Avatar
Casual Pligger
 
Join Date: Mar 2007
Posts: 59
Thanks: 9
Thanked 0 Times in 0 Posts
Yes. same question here. Do we just add that value to the read_basic function?
Reply With Quote
  #6 (permalink)  
Old 06-22-2007, 07:52 PM
Constant Pligger
 
Join Date: Mar 2006
Posts: 575
Thanks: 14
Thanked 126 Times in 61 Posts
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 08:00 PM..
Reply With Quote
  #7 (permalink)  
Old 06-22-2007, 08:48 PM
Genghis's Avatar
Casual Pligger
 
Join Date: Mar 2007
Posts: 59
Thanks: 9
Thanked 0 Times in 0 Posts
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, 09:01 PM
Constant Pligger
 
Join Date: Mar 2006
Posts: 575
Thanks: 14
Thanked 126 Times in 61 Posts
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
The Following 4 Users Say Thank You to Simon For This Useful Post:
Reply

Thread Tools
Display Modes
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
LinkBacks (?)
LinkBack to this Thread: http://forums.pligg.com/bug-report/7093-voting-resets-comment-count-zero-b9-6-a.html
Posted By For Type Date
SourceForge.net Repository - [pligg] Log of /branches/9.x/libs/link.php This thread Refback 07-04-2007 01:36 PM

Similar Threads
Thread Thread Starter Forum Replies Last Post
9.8.1 upgrade: comment count not showing up nothingman General Help 2 02-21-2008 10:01 PM
Comment Count Update Simon Bug Report 4 06-01-2007 09:45 PM
story comment count daone General Help 0 03-06-2007 10:11 AM
How to move Vote count and Vote Label in voting box? koltz Template Support 0 10-29-2006 08:39 PM
Fix comment voting in Safari for Mollio Beat & Paul01 Sacha QS Template Support 1 10-24-2006 12:00 AM


Search Engine Friendly URLs by vBSEO 3.2.0