Skip to content
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

Use the correct user table names when on multisite #66

Merged
merged 3 commits into from
Aug 6, 2020

Conversation

felipeelia
Copy link
Member

@felipeelia felipeelia commented Aug 1, 2020

Description of the Change

Multisite: User and User Meta Table Names

This PR changes the way we are generating the wp_users and wp_usermeta table names. Instead of $GLOBALS['table_prefix'] . 'users' the code would use $wpdb->users. As table_prefix varies in multisite installations depending on the main blog, this seems to a safer way to identify the correct table name.

Multisite: Table Names

I don't know if I got an edge case but the script wasn't finding all tables, just the tables related to the main blog (that was not the original main one). Changing $GLOBALS['table_prefix'] to $wpdb->base_prefix we can get all tables with the "original" prefix set in the wp-config.php file.

As stated in the $wpdb documentation here:

$base_prefix — The original prefix as defined in wp-config.php. For multi-site: Use if you want to get the prefix without the blog number appended.

Column Statistics

Again, I don't know if it was a misconfiguration of my part but I ran into an Unknown table 'COLUMN_STATISTICS' in information_schema error. Adding --column-statistics=0 to all mysqldump calls fixed the issue.

More info in this Server Fault question.

Tablespaces

As per cbfa791, this PR also fixes the mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces errors adding a --no-tablespaces parameter to the mysqldump calls.

Data Escape

As related on #64, there is a lack of escaping in the current code. Commit f7f75cd tries to fix it.

Alternate Designs

I'm open to suggestions.

Benefits

WP Snapshots working good with multi-sites that changed the main blog id :)

Possible Drawbacks

n/a

Verification Process

I've cloned the repository locally and changed it as needed to generate a snapshot for my project.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Applicable Issues

Fixes #65 and #64

Changelog Entry

Fixed user scrubbing on multisites.

This commit also add a `--column-statistics=0` parameter to `mysqldump` calls to
avoid a `mysqldump throws: Unknown table 'COLUMN_STATISTICS' in information_schema`
error
Fix the `mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS
privilege(s) for this operation' when trying to dump tablespaces` Error
@tlovett1
Copy link
Member

tlovett1 commented Aug 6, 2020

This looks solid @felipeelia !

@tlovett1 tlovett1 added the bug label Aug 6, 2020
@tlovett1 tlovett1 merged commit ea0ed0d into 10up:develop Aug 6, 2020
@felipeelia felipeelia deleted the fix/multisite-users-export branch August 6, 2020 21:38
@jeffpaul jeffpaul added this to the 2.0.1 milestone Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multisite User Scrubbing
3 participants