Skip to:

Opened 21 months ago

Closed 20 months ago

Last modified 18 months ago

#1938 closed defect (fixed)

new "Fore index" sql clause conflicting with bbp_has_replies args !

Reported by: villagora Owned by:
Milestone: 2.1.3 Priority: highest
Severity: blocker Version: 2.1
Component: Replies Keywords:
Cc: contact@…



There is a mistake in _bbp_has_replies_where function. You can't change the where clause for add le "force index" like that.
Indeed, if like me, i want to pass args to bbp_has_replie function for make a meta query, a inner join is added to the query before the where clause (and so before the "force index" clause).

And in this case the sql query crash :

SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) FORCE INDEX (PRIMARY, post_parent) WHERE 1=1 AND (wp_posts.ID = 125 OR wp_posts.post_parent = 125) AND wp_posts.post_type IN ('topic', 'reply') AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed') AND (wp_postmeta.meta_key = 'ratings_score' ) GROUP BY wp_posts.ID ORDER BY wp_postmeta.meta_value DESC LIMIT 0, 15

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FORCE INDEX (PRIMARY, post_parent) WHERE 1=1 AND (wp_posts.ID = 125 OR wp_posts.' at line 1

I need a fix, thank you in advance !

Change History (5)

comment:1 johnjamesjacoby20 months ago

  • Milestone changed from Awaiting Review to 2.1.3

Duh. Confirmed, and this is pretty lame. Moving to 2.1.x milestone.

comment:2 johnjamesjacoby20 months ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [4162]) Replies:

  • Do not force single topic query to use specific indexes if also doing a meta query.
  • Fixes #1938 for 2.2 branch.

comment:3 johnjamesjacoby20 months ago

(In [4163]) Replies:

  • Do not force single topic query to use specific indexes if also doing a meta query.
  • Fixes #1938 for 2.1 branch.

comment:4 villagora20 months ago

Thank you JJJ ! :)
But, how can you fix it so that the topic should be displayed at the top of the same replies loop ?

comment:5 tamarazuk18 months ago

@villagora -- Were you able to fix this? If so, how?

I posted a topic on the bbPress Support Forums over 24 hours ago and have not received any help from users yet. (
I am unable to view any topic or reply content on the front end and would love to know how to fix this before I start exploring other forum options.

Note: See TracTickets for help on using tickets.