Skip to content

Minor Changes To Make Multisite Compatible#2758

Draft
shewa12 wants to merge 14 commits into
4.0.0-devfrom
multisite
Draft

Minor Changes To Make Multisite Compatible#2758
shewa12 wants to merge 14 commits into
4.0.0-devfrom
multisite

Conversation

@shewa12

@shewa12 shewa12 commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@shewa12 shewa12 requested a review from harunollyo June 2, 2026 06:30
@shewa12 shewa12 added the 4.0.0 Tutor v4.w0w label Jun 2, 2026
Comment thread helpers/QueryHelper.php Outdated
* @return string
*/
public static function prepare_table_name( string $table_name ) {
global $wpdb;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to modify this method. In multisite env WP handle the prefix.

// @see method implementation inside class-wpdb.php
public function get_blog_prefix( $blog_id = null )

@harunollyo

Copy link
Copy Markdown
Collaborator

WordPress Multisite, site/blog ID 1 is the main site, and its tables are stored without a numeric suffix.
For example, if:

base_prefix = wp_
Blog ID Posts Table
1 wp_posts
2 wp_2_posts
3 wp_3_posts

Comment thread helpers/QueryHelper.php Outdated
public static function get_table_prefix( $table_name ) {
global $wpdb;

if ( is_multisite() ) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use and instead of nested if

Comment thread helpers/QueryHelper.php
@@ -1253,11 +1254,41 @@ public static function get_last_query(){
*

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update comment

Comment thread helpers/QueryHelper.php Outdated
return true;
}

$is_base_table = strpos( $table_name, 'wp_users' ) !== false || strpos( $table_name, 'wp_usermeta' ) !== false;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use loop based on $base_tables

Comment thread helpers/QueryHelper.php Outdated

if ( $wpdb->last_error ) {
error_log( $wpdb->last_error );
$error_msg = (string) $wpdb->last_error;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this prop is string type, why we need to cast it again with another variable to log.
https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wpdb.php#L84

@shewa12 shewa12 marked this pull request as draft June 8, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0.0 Tutor v4.w0w

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants