Skip to content

fix: Multisite table names, dbDelta schemas, and migration guards - #2953

Open
mwenell wants to merge 1 commit into
themeum:masterfrom
mwenell:fix/multisite-compatibility
Open

fix: Multisite table names, dbDelta schemas, and migration guards#2953
mwenell wants to merge 1 commit into
themeum:masterfrom
mwenell:fix/multisite-compatibility

Conversation

@mwenell

@mwenell mwenell commented Aug 11, 2026

Copy link
Copy Markdown

Summary

This PR improves WordPress Multisite support for Tutor LMS 4.0.4. It fixes incorrect global table prefixing (users / usermeta), dbDelta schema issues on network activation, Site Editor REST errors when cart tables are missing, and migration cron fatals on subsites without Tutor tables.

I have made this fix because Tutor LMS was crashing when Wordpress was makingg API calls related to user specific patterns in Gutenberg editor (templates). With these fixes I can use the Tutor LMS in my multisite Wordpress. However, I have not tested everything, only my own things are now working fine.

I hope that you could add these updates in your next update -> I do not need to keep updateing by myself my own multisite version.

I have posted in Wordpress plugin forum (Tutor) at https://wordpress.org/support/topic/multisite-support-has-bugs/

This changes are done by using Cursor and AI.

Problems addressed

  1. Global tables on subsitesQueryHelper::prepare_table_name() produced invalid names like wp_7_usermeta and wp_7_wp_users instead of wp_users / wp_usermeta.
  2. Plugin activation / dbDelta — CREATE TABLE schemas used patterns dbDelta mishandles (unnamed INDEX, inline -- comments, TEXT defaults, FOREIGN KEYs with database-global constraint names on Multisite).
  3. Site Editor / Patterns — REST the_content triggered cart/checkout DB queries on blogs without ecommerce tables.
  4. Cron migrationsquiz_attempt_migrator fatals when wp_N_tutor_quiz_attempts does not exist on network-activated subsites.

Approach

Centralized fix in QueryHelper::prepare_table_name() plus minimal related call sites. No fake per-blog users/usermeta tables. Single-site behavior intended unchanged.

Documentation

See UPSTREAM_FIXES.md in this PR for root cause, file list, and verification steps.

Test plan

  • Multisite subsite: no queries to wp_N_users, wp_N_usermeta, wp_N_wp_users
  • Tutor::create_database() on a subsite without duplicate FK / empty KEY errors
  • Site Editor Patterns reload without missing tutor_carts fatals
  • quiz_attempt_migrator cron on blog without Tutor tables does not fatal
  • Single-site: table naming unchanged

Environment

  • WordPress 7.0.2 Multisite
  • Tutor LMS 4.0.4
  • Custom prefix example: main wp_, subsite wp_7_

Happy to adjust based on your coding standards or split into smaller PRs if preferred.

Resolve incorrect global users/usermeta prefixing on Multisite subsites,
make create_database() dbDelta-compatible, skip cart templates during REST,
and prevent migration cron fatals when Tutor tables are missing per blog.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant