[buddypress-trac] [BuddyPress] #3805: error dump in error_log after calls to BP_XProfile_Group->get

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Wed Dec 7 19:08:55 UTC 2011


#3805: error dump in error_log after calls to BP_XProfile_Group->get
--------------------------+-----------------------------
 Reporter:  ppostma1      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Core          |    Version:
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 The log files are flooded with the following:
  WordPress database error Table 'mywordpress_wpdb.g' doesn't exist for
 query SELECT DISTINCT g.* FROM  g  ORDER BY g.group_order ASC made by
 require, require_once, require_once, require_once, do_action,
 call_user_func_array, xpa_plugin_init_action,
 BPxProfileACL->BPxProfileACL, BP_XProfile_Group->get


 In the file: buddypress/bp-xprofile/bp-xprofile-classes.php i tracked it
 down to this line:
 $groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT g.* FROM
 {$bp->profile->table_name_groups} g INNER JOIN
 {$bp->profile->table_name_fields} f ON g.id = f.group_id {$where_sql}
 ORDER BY g.group_order ASC" ) );

 and the similar line following that.
 $bp->profile->table_name_(groups|field|data) is null when the query is
 built.


 I added this to the function get:

 if($_GET[['pdbg']]){
   if(isset($bp->profile))
     print_r($bp->profile);
   else
     print_r($bp);
 }



 which produced this result from the ->profile each time:
 BP_XProfile_Component Object
 (
     [name] => Extended Profiles
     [id] => xprofile
     [slug] =>
     [has_directory] =>
     [path] => /..../public_html/wp-content/plugins/buddypress
     [query] =>
     [current_id] =>
     [notification_callback] =>
     [admin_menu] =>
 )
 BP_XProfile_Component Object
 (
     [name] => Extended Profiles
     [id] => xprofile
     [slug] => profile
     [has_directory] =>
     [path] => /..../public_html/wp-content/plugins/buddypress
     [query] =>
     [current_id] =>
     [notification_callback] => xprofile_format_notifications
     [admin_menu] =>
     [field_types] => Array
         (
             [0] => textbox
             [1] => textarea
             [2] => radio
             [3] => checkbox
             [4] => selectbox
             [5] => multiselectbox
             [6] => datebox
         )

     [root_slug] =>
     [search_string] =>
     [table_name_data] => wp_bp_xprofile_data
     [table_name_groups] => wp_bp_xprofile_groups
     [table_name_fields] => wp_bp_xprofile_fields
     [table_name_meta] => wp_bp_xprofile_meta
 )

 The first time ::get is called, bp->profile is missing the table names but
 gets set before subsequent calls. I patched it by adding this:

 if(isset($bp->profile->table_name_groups)) {
    $table_name_groups = $bp->profile->table_name_groups;
    $table_name_fields = $bp->profile->table_name_fields;
    $table_name_data = $bp->profile->table_name_data;
    //#table_name_meta not used in this function
 } else {
    $table_name_groups = 'wp_bp_xprofile_groups';
    $table_name_fields = 'wp_bp_xprofile_fields';
    $table_name_data = 'wp_bp_xprofile_data';
 }

 and changed all references of
 {$bp->profile->table_name_(groups|fields|data)} to
 {$table_name_(groups|fields|data)}

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


More information about the buddypress-trac mailing list