#7834 closed defect (bug) (fixed)
WordPress Changeset 42836 introduces conflict with BuddyPress `blogmeta` table
Reported by: | needle | Owned by: | djpaul |
---|---|---|---|
Milestone: | 4.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Blogs | Keywords: | dev-feedback |
Cc: | needle |
Description
WordPress Changeset 42836 introduces the $wpdb->blogmeta
table into core. Existing multisite BuddyPress installs with the Site Tracking component active already have the $wpdb->bp_user_blogs_blogmeta
table installed and refer to it via the blogmeta
property of the $wpdb
object.
There are two consequences of this:
1) The WordPress "Upgrade Network" routine fails to install the core $wpdb->blogmeta
table because is_site_meta_supported()
erroneously reports true
due to the existence of the $wpdb->bp_user_blogs_blogmeta
table.
2) Queries performed after BuddyPress alters $wpdb
throw SQL errors of the following form:
[16-May-2018 10:14:16 UTC] WordPress database error Unknown column 'meta_id' in 'order clause' for query SELECT blog_id, meta_key, meta_value FROM wp_bp_user_blogs_blogmeta WHERE blog_id IN (2,3,4) ORDER BY meta_id ASC made by require_once('wp-admin/network/admin.php'), require_once('wp-admin/admin.php'), do_action('admin_init'), WP_Hook->do_action, WP_Hook->apply_filters, _wp_admin_bar_init, WP_Admin_Bar->initialize, get_blogs_of_user, get_sites, WP_Site_Query->query, WP_Site_Query->get_sites, _prime_site_caches, update_site_cache, update_sitemeta_cache, update_meta_cache
The query above is intended for the $wpdb->blogmeta
table but gets routed to the $wpdb->bp_user_blogs_blogmeta
table instead.
tl;dr BuddyPress and/or WordPress need a disambiguation exercise to resolve this name clash.
Attachments (1)
Change History (18)
#4
@
7 years ago
- Milestone changed from Awaiting Review to 3.1
This won't impact us until WP 5.0 ships, so there's no need to rush it into 3.0.
#5
@
7 years ago
- Cc needle added
@DJPaul Any thoughts on how to develop with WordPress and BuddyPress bleeding edge in the meantime?
#7
@
7 years ago
@needle on a fresh install i'd probably try to filter 'bp_blogs_global_tables'
and return array( $GLOBALS['wpdb']->blogmeta )
#8
@
7 years ago
bp_blog.patch
renames our existing blog meta entry to $wpdb->bp_blogmeta
.
This is a quick patch to ensure no conflicts for WP 5.0, but currently means that there are two blog meta tables -- WP's version and our version.
The alternative approach would probably mean migrating our existing blog meta data to WP's new blogmeta
table, but we would have to wait until WP 5.0 for this.
#10
@
7 years ago
Thanks a lot for your work on the patch @r-a-y I’m in favor of using the WordPress generated table as it’s a bit too bad to have the same table twice with a different name 😊.
Instead of prefixing the table name, the meta keys could be BP prefixed if there are some fears to introduce a mess with plugins that could use similar meta key names :)
I also think, it could be a nice opportunity to have an upgrade tool to fix some other areas like favorites one of these days 😉
#11
@
7 years ago
Thanks for the feedback, @imath.
Instead of prefixing the table name, the meta keys could be BP prefixed if there are some fears to introduce a mess with plugins that could use similar meta key names :)
We do need to prefix the table name if we're keeping a separate blog meta table due to how WordPress looks for the global property in the $wpdb
global in _get_meta_table()
:
https://core.trac.wordpress.org/browser/branches/4.9/src/wp-includes/meta.php?marks=42,47,904#L889
However, if we decide to migrate our data to WP's blog meta table, then prefixing the meta key should be doable. When we do the migration, we would change all our meta keys to add our prefix. Then in our blog meta functions, we would just automatically add the prefix during lookups to avoid breaking existing blog meta entries.
I also think, it could be a nice opportunity to have an upgrade tool to fix some other areas like favorites one of these days 😉
Agreed!
#12
@
7 years ago
Let’s have this ticket focus on fixing the existing implementation, if only because that’s quicker to get done, and doesn’t involve changing to require a new version of WordPress.
Ouch. Nice spot @needle.
BP_Blogs_Component->setup_globals()
($meta_tables
) -->BP_Component->register_meta_tables()