Opened 13 years ago
Closed 13 years ago
#3805 closed defect (bug) (no action required)
error dump in error_log after calls to BP_XProfile_Group->get
Reported by: | ppostma1 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 1.5.2 |
Component: | Core | Keywords: | |
Cc: |
Description
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($_GETpdbg?){
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)}
Change History (3)
#2
@
13 years ago
Can you post a trace log of what causes this function to be ran before the tables are instantiated?
#3
@
13 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
- Version set to 1.5.2
Looks like it's the xpa_plugin_init_action() function, which is not BuddyPress core. Closing as invalid. Reopen if more information becomes available that says otherwise.
patched = my local code, not something submitted to any repository