[buddypress-trac] [BuddyPress] #4314: Invalid SQL query in BP_Groups_Group->get_global_forum_topic_count()

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Fri Jun 29 15:46:42 UTC 2012

#4314: Invalid SQL query in BP_Groups_Group->get_global_forum_topic_count()
 Reporter:  DJPaul        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Groups        |    Version:  1.5.5
 Severity:  normal        |   Keywords:
 I am seeing the following message on a group's front page when there is a
 widget in the sidebar which uses the groups loop:

 `[29-Jun-2012 15:39:00] WordPress database error 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 '(gm.meta_key = 'forum_id' AND
 gm.meta_value = t.forum_id) AND t.topic_status = '' at line 1 for query
 SELECT COUNT(t.topic_id) FROM wp_bb_topics AS t, wp_bp_groups AS g LEFT
 JOIN wp_bp_groups_groupmeta AS gm ON g.id = gm.group_id WHERE (gm.meta_key
 = 'forum_id' AND gm.meta_value = t.forum_id) AND g.status = 'public' AND
 t.topic_status = '0' AND t.topic_sticky != '2' (gm.meta_key = 'forum_id'
 AND gm.meta_value = t.forum_id) AND t.topic_status = '0'  made by require,
 wp, WP->main, do_action_ref_array, call_user_func_array, bp_screens,
 do_action, call_user_func_array, groups_screen_group_home,
 bp_core_load_template, load_template, require_once, locate_template,
 load_template, require_once, dynamic_sidebar, call_user_func_array,
 WP_Widget->display_callback, Latest_Activity_Widget->widget,
 bp_has_forum_topics, BP_Forums_Template_Forum->__construct,

 The Latest_Activity_Widget is custom and is super simple, I can share the
 code for that privately if needed. In
 BP_Groups_Group->get_global_forum_topic_count(), the $extra_sql parameter
 is set from $bp->groups->filter_sql. It does not include an "AND" at the
 start of the statement, making the query invalid.

 This does not exist on BP 1.2.10, and I'm seeing it when upgrading a site
 straight to 1.5.5. Can anyone else recreate this issue?

Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4314>
BuddyPress <http://buddypress.org/>

More information about the buddypress-trac mailing list