Fixing WordPress Multisite Compatibility Issues in Tutor LMS#2750
Open
commercial-hippie wants to merge 1 commit into
Open
Fixing WordPress Multisite Compatibility Issues in Tutor LMS#2750commercial-hippie wants to merge 1 commit into
commercial-hippie wants to merge 1 commit into
Conversation
Author
|
Related #2169 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR resolves multiple database, schema installation, and page-rendering bugs when running Tutor LMS on a WordPress Multisite network (specifically where subsites use a custom table prefix like
wp_2_).1. Bypassing Subsite Prefixes for Shared Global Tables
wp_users,wp_usermeta,wp_blogs, etc., are shared network-wide and do not receive subsite prefixes. Tutor LMS'sQueryHelper::prepare_table_name()automatically prepends the subsite table prefix (wp_2_) to all incoming tables, causing SQL execution failures likeTable 'wp_2_wp_users' doesn't exist.QueryHelper::prepare_table_name()to recognize all standard global WordPress tables (e.g.$wpdb->users,$wpdb->usermeta,$wpdb->blogs, etc.) and return them unmodified without prepending the prefix.2. Resolving Hardcoded Foreign Key Constraint Name Conflicts
fk_tutor_itemmeta,fk_tutor_ordermeta_order_id, etc.) in its table creation SQL statements. Activating or upgrading the plugin on a second subsite would fail witherrno: 150 (Foreign key constraint is incorrectly formed)because the constraint name was already registered by the primary site.Tutor.phpandUpgrader.phpto dynamically prefix all database constraints with{$wpdb->prefix}(e.g.,fk_{$wpdb->prefix}tutor_itemmeta), preventing schema conflicts across multiple sites.3. Resolving Instructor Dashboard Render Crash
/dashboard/page crashed (showing only the header and failing to render the content/footer) becauseWithdrawModel::get_withdraw_summaryhardcoded the query source asFROM {$wpdb->prefix}users u. Since there is no site-specific users table (wp_2_users), the query threw a fatal SQL exception.WithdrawModel.phpto reference the global$wpdb->userstable instead.