Topic paging issue
-
I’ve just had a report from one of my forum users saying that occasionally the topic will not return the actual number of posts, and therefore the last page link doesn’t show up.
In the example there was a topic with 122 posts over 4 pages. The forum stated there were 120 posts over three pages. Latest reply listed the last person who posted but had a link to the last post on page 3 (post 120), and not post 122 on page 4.
I deleted one post and then undeleted it. This solved the problem.
I’m not sure what caused it, or how to replicate it. Could this be a bug in bbP or perhaps something I’m doing?
-
Yes, I did. I have recounted everything again, just to be sure.
Interesting – did you say you know how to use phpmyadmin? or no?
The “no deleted posts to count” is disturbing – that is wrong.
You definitely deleted post 24 on that topic right?
I do know how to use it. I just can’t recall if I messed with it relating bbpress before this happened.
Okay we need to see if the query is failing somehow.
try this (assuming the table is bb_posts)
SELECT topic_id, COUNT(post_status) as topic_posts FROM bb_posts WHERE post_status=0 AND topic_id=12
See if that gives 80 or 81
Then try this if that gives 81
SELECT topic_id, COUNT(*) as topic_posts FROM bb_posts WHERE post_status=0 AND topic_id=12
(sorry I forgot to add AND topic_id=12)
This query gave me an error:
#1140 - Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
So I just did this:
SELECT * FROM
bb_postsWHERE topic_id=12
And the result is:
Showing rows 0 – 29 (80 total, Query took 0.0020 sec)
So now I’m wondering where is bbpress taking post count numbers from?
So there are total of 80 posts in this topic with no ‘deleted’ posts. And that means I actually have removed post #24 physically from database.
Maybe I should just create a dummy post on database and problem would solve itself?
I forgot to add the topic_id=12 and group by on my queries sorry.
Well the numbers are coming from post position.
But still something is very wrong, because bbpress is showing
81
as the post count.You need to run the exact query that the recount function uses.
SELECT topic_id, COUNT(post_status) as topic_posts FROM bb_posts WHERE post_status=0 AND topic_id=12 GROUP BY topic_id
See if that gives 80 or 81
Query returns 80 posts. Definitely something is very wrong…
Okay what is happening is that the new recount in bbpress 1.0.2 is failing.
It’s getting the correct number of posts, it’s just not updating the table.
I am investigating (while trying to do 3 other things right now, lol)
Thinking out loud here, don’t do anything yet on your own.
This is Sam’s new routine in 1.0.2 based on my alternate recount for bbpress 0.9
$sql = “INSERT INTO
$bbdb->topics
(topic_id
,topic_posts
)(SELECT
topic_id
, COUNT(post_status
) astopic_posts
FROM
$bbdb->posts
WHERE
post_status
= ‘0’ GROUP BYtopic_id
)ON DUPLICATE KEY UPDATE
topic_posts
= VALUES(topic_posts
);“;
I will investigate further…
OK, so I was going thru the database and saw that bbpress holds post count in it. I just changed that to correct value and it seems like everything is good now. And post #24 is no longer missing, posts have shifted per one place.
Thank you for your help. Anyway now we have discovered one more bug to fix.
Yes but I didn’t want you to do that.
We need to find out why the post count is failing to update.
Or you will just keep running into the same problem over and over.
Actually I guess I can simulate the problem on a test copy.
Yes, sorry, I saw your post when it was too late.
I will try to recreate this situation on new topic.
Actually I can simulate the problem on a test copy.
I’ve just got three other things going on right now so this is taking me longer than the few minutes it should have taken to investigate
That query IS working properly on my test copy.
I purposely changed the topic_posts on a topic from 46 to 99.
Then ran this
INSERT INTO bb_topics (topic_id, topic_posts)
(SELECT topic_id, COUNT(post_status) as topic_posts
FROM bb_posts
WHERE post_status = '0' GROUP BY topic_id)
ON DUPLICATE KEY UPDATE topic_posts = VALUES(topic_posts);and it reverted it back to 46
So try changing the 80 to 81
then try the above query and see if it changes it back to 80 or not?
So here it is:
http://e-motion.lt/bbpress/topic/31?replies=20#post-317
I have deleted post #3 from database. Same problem:
#3 is missing and it shows post count of 21.
After running your query post count is now correct (20), but #3 is still being skipped.
the deleted post will always causing missing numbers
that is because in your template the number is based on post-position which is never updated
the important part is that the count changes from 21 to 20
the question is why when you run the direct recount within bbpress itself, it did not change that 81 to 80, but the manual query changes 21 to 20
if you want those numbers to be continous on the page, you’d have to change your template but it doesn’t affect how bbpress works
you can try an experiment to change the 20 to 21 and/or the 80 to 81 (I see you deleted posts the so the 80 is now 69)
then do a bbpress recount
see if it changes or not
if it doesn’t change, try the manual way
if the manual works but bbpress does not, then there is a bug in how bbpress is doing it that is causing a silent error and it fails
It looks like I am missing something – when I changed post count on original thread from 81 to 80, all post numbers shifted and #24 is no longer missing. But anyway, I am OK with missing numbers, at least it lets people know where their posts are.
How can I check why my bbpress does not recount posts? Where is that function? I was messing around with some PHP and template codes (to ‘join’ forum to the page) so maybe I have done something…
I mean just to try it from admin after you alter the count on purpose.
You should not be hacking the admin functions, recount are in their own file anyway.
Huh. The post numbering did reset. That is strange.
What theme is that – I’d have to see the post.php to see what function they are using between
<div class="postnumber"></div>
I see a few people using neoease for bbPress but I can’t find it anywhere? Where did you get it? Or is that inove with your own modifications?
The theme, basically, is default “Kakumei” with altered header and footer.
Kakumei doesn’t have post numbering from what I see, neither does inove.
Take a peek inside your
post.php
template and tell me what’s between<div class="postnumber"> </div>
It’s also possible that it is in
topic.php
instead.
- You must be logged in to reply to this topic.