-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a DB Error when BP Blogs component is active on a regular WP #501
Conversation
Request to achieve `buddypress/v1/activity?_embed=1` to reproduce the issue
🤔 I can't replicate this, btw. Tested on a fresh install with BP 12.4.0. What's the DB error you see? |
Actually, I forgot to add the
|
Interesting 🧐. First, if you use the 12.4.0 BP stable version, I'm not sure the BP REST plugin is used even if activated, I believe it's using the built REST endpoints of BuddyPress. The fact a regular endpoint ends up having no route is very weird, have you customized the If I've found the issue with the activity endpoint, I think you can more easily get it trying to reach any Blogs component endpoint making sure the component is active and BuddyPress is activated on a NON Multisite config. A regular WP. This endpoint's goal is to list blogs, it shouldn't be loaded in regular configs because there's only one blog. The BP REST plugin unlike BuddyPress is loading it... The failing unit tests are proving it. |
Give me a minute to test it again. I was not using the BP REST plugin. |
Here's the error I get: [16-Apr-2024 17:15:44 UTC] WordPress database error Table 'develop_buddypress.wp_blogs' doesn't exist for query
SELECT b.blog_id, b.user_id as admin_user_id, u.user_email as admin_user_email, wb.domain, wb.path, bm.meta_value as last_activity, bm_name.meta_value as name
FROM
wp_bp_user_blogs b
LEFT JOIN wp_bp_user_blogs_blogmeta bm ON (b.blog_id = bm.blog_id)
LEFT JOIN wp_bp_user_blogs_blogmeta bm_name ON (b.blog_id = bm_name.blog_id)
LEFT JOIN wp_bp_user_blogs_blogmeta bm_description ON (b.blog_id = bm_description.blog_id)
LEFT JOIN wp_blogs wb ON (b.blog_id = wb.blog_id)
LEFT JOIN wp_users u ON (b.user_id = u.ID)
WHERE
wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0
AND bm.meta_key = 'last_activity' AND bm_name.meta_key = 'name' AND bm_description.meta_key = 'description'
AND b.blog_id IN (1)
GROUP BY b.blog_id ORDER BY bm.meta_value DESC LIMIT 0, 20
made by require_once('wp-admin/admin-header.php'), do_action('admin_enqueue_scripts'), WP_Hook->do_action, WP_Hook->apply_filters, bp_admin_enqueue_scripts, do_action('bp_admin_enqueue_scripts'), WP_Hook->do_action, WP_Hook->apply_filters, bp_activity_admin_enqueue_assets, array_reduce, rest_preload_api_request, WP_REST_Server->response_to_data, WP_REST_Server->embed_links, WP_REST_Server->dispatch, WP_REST_Server->respond_to_request, BP_REST_Blogs_Endpoint->get_item, BP_REST_Blogs_Endpoint->get_blog_object, bp_blogs_get_blogs, BP_Blogs_Blog::get |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed! Makes sense. We are trying to get a blog without having any available.
Fix looks good!
Steps to reproduce the DB error:
new_blog_post
activitybuddypress/v1/activity?_embed=1
You should get the DB Error, I believe you can also get it trying to get the root blog using the corresponding endpoint.
I believe it’s only impacting the BP REST plugin as the Blogs REST Controller is only loaded when Multisite is active and a stable BuddyPress release is used. See https://github.com/buddypress/buddypress/blob/ef9fde9191b87a2f6a4027f2ecc75cfc1c616090/src/bp-blogs/classes/class-bp-blogs-component.php#L508