Skip to:
Content

bbPress.org

Opened 12 years ago

Last modified 13 months ago

#1962 new defect (bug)

BBpress does not get the right reply url if you change replies loop args.

Reported by: villagora's profile villagora Owned by:
Milestone: Future Release Priority: omg sweet tea
Severity: major Version: 2.1.2
Component: Tools - Code Improvements Keywords: needs-patch
Cc: contact@…

Description

Hi,

I've modify the replies loop args for display last reply first ('orderby' => 'date', 'order' => 'DSC'); But if I post a new reply, BBpress redirect to the reply URL get by bbp_get_reply_url() function without paying attention to the order defined in the loop. So BBpress get the wrong page for my new reply (the last, instead of the first) and I'm redirect to the last page without my new reply.

That's a huge problem because, some one can reorder the replies by another value, by a metavalue for exemple. so the page returned must be calculated according to the display loop used.

NB : There are perhaps the same mistake for topics.

I hope you can implement that quickly. Thanks in avance...

Change History (7)

#1 in reply to: ↑ description ; follow-up: @alexvorn2
12 years ago

do you mean using query_posts() ?

#2 in reply to: ↑ 1 ; follow-up: @villagora
12 years ago

Replying to alexvorn2:

do you mean using query_posts() ?

No, I pass args directly to bbp_has_replies function in my custom bbpress theme compat ! ;)
But it's the same thing if you hook bbp_has_replies filter for make your own query...

#3 in reply to: ↑ 2 ; follow-up: @alexvorn2
12 years ago

Replying to villagora:

Replying to alexvorn2:

do you mean using query_posts() ?

No, I pass args directly to bbp_has_replies function in my custom bbpress theme compat ! ;)
But it's the same thing if you hook bbp_has_replies filter for make your own query...

I see... Do you have an idea how to fix it?

#4 in reply to: ↑ 3 @villagora
12 years ago

This quick and dirty solution seems to make the trick (copy/paste line 355 in bbp-reply-template.php):

I need to replace bbp_get_reply_position by another function like bbp_get_loop_reply_position. for this stuff, indeed, I can use query_posts() and count manually the new reply position ($reply_id here) :

//get the user query 
global $query_string;
                
// The Query
query_posts( $query_string );
$position = 1;

// The Loop
while ( have_posts() ) : the_post();
if (get_the_ID()==$reply_id)
  break;
else
  $position++;
endwhile;

// Reset Query
wp_reset_query();

$reply_page = ceil( (int) $position / (int) bbp_get_replies_per_page() );

That works, but I don't know how we could do without this extra loop ..?

#5 @johnjamesjacoby
12 years ago

  • Milestone changed from Awaiting Review to Future Release
  • Priority changed from high to normal

The solution above is pretty bad. Even so, this needs to get bumped to future release.

For now, the return values of bbp_get_reply_url() and bbp_get_reply_position() can be filtered if you need to customize them.

#6 @Chaton666
9 years ago

  • Keywords needs-patch added

Hi,
I have the same problem here with the bbp_topic_freshness_link() function (loop-single-topic.php), is there any solution since the first ticket ?
Thanks,
Marie.

#7 @codestars
4 years ago

  • Priority changed from normal to omg sweet tea

I fixed this issue for my website in bbpress/includes/replies/template.php on line 470:
Change this line:
$reply_page = ceil( (int) bbp_get_reply_position( $reply_id, $topic_id ) / (int) bbp_get_replies_per_page() );
Into this:
$reply_page = ceil( (int) bbp_get_reply_position_raw( $reply_id, $topic_id ) / (int) bbp_get_replies_per_page() );

Problem solved! The topic and forum freshness permalinks work now as they should with the right pagination. Hope the bbpress team will apply this patch so we don't have to hack the core plugin file like this.

Cheers!

Last edited 4 years ago by codestars (previous) (diff)
Note: See TracTickets for help on using tickets.