Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Thread postcount error

Locked Asked Modified Viewed 4,143 times
A
Arda
A
Arda 10
  • Member, joined since
  • Contributed 150 posts on the community forums.
  • Started 11 threads in the forums
  • Started this discussions
asked
Member

hi, ive upgraded from 6.01.15 to 7.0 rc1 , at the latest forum threads panel or latest forums panel etc, all of the counts of threads are broken, they're nearly all -1
i think there was an error in upgrading step 4, so i ran this code again at custom pages in v7, and it says done, but yet they're still buggy (after a post made to thread, that thread's fixed)
<?php
$result = dbquery("SELECT COUNT(post_id) AS count, ".$db_prefix."posts.thread_id, ".$db_prefix."threads.thread_postcount
FROM ".$db_prefix."posts
JOIN ".$db_prefix."threads ON ".$db_prefix."threads.thread_id = ".$db_prefix."posts.thread_id
WHERE thread_postcount = 0
GROUP BY thread_id");

if (dbrows($result)) {
while ($data = dbarray($result)) {
$result = dbquery("UPDATE ".$db_prefix."threads SET thread_postcount='".$data['count']."' WHERE thread_id='".$data['thread_id']."'");
}
}

$result = dbquery("SELECT SUM(thread_postcount) AS postcount, ".$db_prefix."threads.forum_id, ".$db_prefix."forums.forum_postcount
FROM ".$db_prefix."threads
JOIN ".$db_prefix."forums ON ".$db_prefix."forums.forum_id = ".$db_prefix."threads.forum_id
WHERE forum_postcount = 0
GROUP BY forum_id");

if (dbrows($result)) {
while ($data = dbarray($result)) {
$result = dbquery("UPDATE ".$db_prefix."forums SET forum_postcount='".$data['postcount']."' WHERE forum_id='".$data['forum_id']."'");
}
}

$result = dbquery("SELECT COUNT(thread_id) AS threadcount, ".$db_prefix."threads.forum_id, ".$db_prefix."forums.forum_threadcount
FROM ".$db_prefix."threads
JOIN ".$db_prefix."forums ON ".$db_prefix."forums.forum_id = ".$db_prefix."threads.forum_id
WHERE forum_threadcount = 0
GROUP BY forum_id");

if (dbrows($result)) {
while ($data = dbarray($result)) {
$result = dbquery("UPDATE ".$db_prefix."forums SET forum_threadcount='".$data['threadcount']."' WHERE forum_id='".$data['forum_id']."'");
}
}

$result = dbquery("SELECT MAX(post_id) AS lastpid, ".$db_prefix."posts.thread_id, ".$db_prefix."threads.thread_lastpostid
FROM ".$db_prefix."posts
JOIN ".$db_prefix."threads ON ".$db_prefix."threads.thread_id = ".$db_prefix."posts.thread_id
WHERE thread_lastpostid = 0
GROUP BY thread_id");

if (dbrows($result)) {
while ($data = dbarray($result)) {
$result = dbquery("UPDATE ".$db_prefix."threads SET thread_lastpostid='".$data['lastpid']."' WHERE thread_id='".$data['thread_id']."'");
}
}
echo $result?"done":"not done<br>".mysql_error($result);
?>


how do i fix it, thanks :)

edit: recounting user posts at settings_misc does not work
Edited by Arda on 22-06-2008 22:58,
0 replies

11 posts

K
Kenneth
K
/Kenneth
  • Junior Member, joined since
  • Contributed 23 posts on the community forums.
  • Started 1 thread in the forums
answered
Junior Member

Experienced the same thing when I did an update on one of my sites...
0 replies
F
Falk
F
Falk 146
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 12 questions
answered
Super Admin

Could be a mysql incompatability, try this in custom pages:

<?php
$res = dbquery("SELECT COUNT(post_id) AS count, ".DB_POSTS.".thread_id, ".DB_THREADS.".thread_postcount
FROM ".DB_POSTS."
JOIN ".DB_THREADS." ON ".DB_THREADS.".thread_id = ".DB_POSTS.".thread_id
WHERE thread_postcount = 0
GROUP BY thread_id");

if(dbrows($res) > 0){
   echo "Counting posts per thread <br/>\n";
   while($data = dbarray($res)){
      echo "...";
      if(abs(microtime() - $start) < 20){
         dbquery("UPDATE ".DB_THREADS." SET thread_postcount='".$data['count']."' WHERE thread_id='".$data['thread_id']."'");
      }else{
         header("Location: ".FUSION_SELF."?continue=1");
      }
   }
   echo "done <br/>\n";
}


$res = dbquery("SELECT SUM(thread_postcount) AS postcount, ".DB_THREADS.".forum_id, ".DB_FORUMS.".forum_postcount
FROM ".DB_THREADS."
JOIN ".DB_FORUMS." ON ".DB_FORUMS.".forum_id = ".DB_THREADS.".forum_id
WHERE forum_postcount = 0
GROUP BY forum_id");

if(dbrows($res) > 0){
   echo "Counting posts per forum <br/>\n";
   while($data = dbarray($res)){
      echo "...";
      if(abs(microtime() - $start) < 20){
         dbquery("UPDATE ".DB_FORUMS." SET forum_postcount='".$data['postcount']."' WHERE forum_id='".$data['forum_id']."'");
      }else{
         header("Location: ".FUSION_SELF."?continue=1");
      }
   }
   echo "done <br/>\n";
}


$res = dbquery("SELECT COUNT(thread_id) AS threadcount, ".DB_THREADS.".forum_id, ".DB_FORUMS.".forum_threadcount
FROM ".DB_THREADS."
JOIN ".DB_FORUMS." ON ".DB_FORUMS.".forum_id = ".DB_THREADS.".forum_id
WHERE forum_threadcount = 0
GROUP BY forum_id");

if(dbrows($res) > 0){
   echo "Counting threads per forum <br/>\n";
   while($data = dbarray($res)){
      echo "...";
      if(abs(microtime() - $start) < 20){
         dbquery("UPDATE ".DB_FORUMS." SET forum_threadcount='".$data['threadcount']."' WHERE forum_id='".$data['forum_id']."'");
      }else{
         header("Location: ".FUSION_SELF."?continue=1");
      }
   }
   echo "done <br/>\n";
}


$res = dbquery("SELECT MAX(post_id) AS lastpid, ".DB_POSTS.".thread_id, ".DB_THREADS.".thread_lastpostid
FROM ".DB_POSTS."
JOIN ".DB_THREADS." ON ".DB_THREADS.".thread_id = ".DB_POSTS.".thread_id
WHERE thread_lastpostid = 0
GROUP BY thread_id");

if(dbrows($res) > 0){
   echo "Calculating IDs of latest posts <br/>\n";
   while($data = dbarray($res)){
      echo "... ";
      if(abs(microtime() - $start) < 20){
      dbquery("UPDATE ".DB_THREADS." SET thread_lastpostid='".$data['lastpid']."' WHERE thread_id='".$data['thread_id']."'");
      }else{
         header("Location: ".FUSION_SELF."?continue=1");
      }
   }
   echo "done <br/>\n";
}

echo "Ok";

?>
Edited by Falk on 23-06-2008 00:02,
0 replies
A
Arda
A
Arda 10
  • Member, joined since
  • Contributed 150 posts on the community forums.
  • Started 11 threads in the forums
  • Started this discussions
answered
Member

yes, it worked! thanks digi :) (but u've to delete the code "}" at line 82)
0 replies
F
Falk
F
Falk 146
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 12 questions
answered
Super Admin

Splendid.
0 replies
S
stranded
S
  • Member, joined since
  • Contributed 183 posts on the community forums.
  • Started 53 threads in the forums
answered
Member

Clicking threads with -1 fixes them eventually, just open a thread and it shows the right number after that. Doesn't really bother me that much.
0 replies
D
dewa5227
D
  • Member, joined since
  • Contributed 51 posts on the community forums.
  • Started 5 threads in the forums
answered
Member

digi i got this x_x when i preview that in custom page, but it still working well 0_0
Notice: Undefined variable: start in /home2/dbests/public_html/administration/custom_pages.php(88) : eval()'d code on line 12
0 replies
A
Arda
A
Arda 10
  • Member, joined since
  • Contributed 150 posts on the community forums.
  • Started 11 threads in the forums
  • Started this discussions
answered
Member

Quote

dewa5227 wrote:
digi i got this x_x when i preview that in custom page, but it still working well 0_0
Notice: Undefined variable: start in /home2/dbests/public_html/administration/custom_pages.php(88) : eval()'d code on line 12


it's nothing serious, just you've to edit php.ini for notifications

Quote

stranded wrote:
Clicking threads with -1 fixes them eventually, just open a thread and it shows the right number after that. Doesn't really bother me that much.


it's not count of reads, but count of posts :)

edit: yes u're right i re-checked
Edited by Arda on 23-06-2008 11:40,
0 replies
M
Matonor
M
Impossible things are there to be made possible
  • Veteran Member, joined since
  • Contributed 1,022 posts on the community forums.
  • Started 3 threads in the forums
answered
Veteran Member

digi forgot $start = microtime(); at the top I assume.
stranded is right. the post count values are auto-fixing themselves when you are viewing threads.
0 replies
S
stranded
S
  • Member, joined since
  • Contributed 183 posts on the community forums.
  • Started 53 threads in the forums
answered
Member

Quote

it's not count of reads, but count of posts :)


that's what I meant lol :D

at least now I see clearly which threads on my forums users are reading at all :D
0 replies
F
Falk
F
Falk 146
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 12 questions
answered
Super Admin

To folks encountering prob, i need sa access to your site to diagnose, please pm me.
0 replies
D
dewa5227
D
  • Member, joined since
  • Contributed 51 posts on the community forums.
  • Started 5 threads in the forums
answered
Member

nah, it's good now :D
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 11 posts
  • Votes 0 votes
  • Topic users 6 members

6 participants

F
F
Falk 146
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 12 questions
M
M
Impossible things are there to be made possible
  • Veteran Member, joined since
  • Contributed 1,022 posts on the community forums.
  • Started 3 threads in the forums
K
K
/Kenneth
  • Junior Member, joined since
  • Contributed 23 posts on the community forums.
  • Started 1 thread in the forums
A
A
Arda 10
  • Member, joined since
  • Contributed 150 posts on the community forums.
  • Started 11 threads in the forums
  • Started this discussions
D
D
  • Member, joined since
  • Contributed 51 posts on the community forums.
  • Started 5 threads in the forums
S
S
  • Member, joined since
  • Contributed 183 posts on the community forums.
  • Started 53 threads in the forums

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet