Fixes #118: On multisite-convert, don't assume site_id is 1#122
Merged
schlessera merged 5 commits intowp-cli:masterfrom Oct 8, 2019
andyzito:118-site-id
Merged
Fixes #118: On multisite-convert, don't assume site_id is 1#122schlessera merged 5 commits intowp-cli:masterfrom andyzito:118-site-id
schlessera merged 5 commits intowp-cli:masterfrom
andyzito:118-site-id
Conversation
schlessera
requested changes
May 2, 2019
Contributor
Author
|
I made two changes to the code:
|
schlessera
requested changes
May 9, 2019
Member
|
@azito122 Are you still interested in working on this? |
Co-Authored-By: Alain Schlesser <alain.schlesser@gmail.com>
Co-Authored-By: Alain Schlesser <alain.schlesser@gmail.com>
Contributor
Author
|
@schlessera Yes. Apologies for going radio silent. I've made the last changes you requested and rebased. |
schlessera
approved these changes
Oct 8, 2019
Member
|
Thanks for the PR, @azito122 ! |
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.
In the
populate_networkfunction, which is used bycore multisite-convert, I observe the following code (line 1007 ofwp-admin/includes/schema.phpat v4.9.9):My understanding of the code in
Core_Command.phpis thatmultisite-convertis invokingpopulate_network(), and passing1as the site id ($network_id). As you can see, the WP core code then sets the network_id equal to the result of the INSERT query against wp_site. In most cases, this would be 1; however, if one has configured auto_increment_increment -- as is standard practice for database clusters -- then thewp_sitetable will store the site as id 4, and the code will generate the rest of the data using that same id.From the perspective of
core-command, this is mostly not a concern. However, it does appear that the constantSITE_ID_CURRENT_SITEis hardcoded with value 1. This produces an inconsistency between the config file and the database which is less than ideal. The solution is simple -- store the actual site_id/network_id and use that instead of a hardcoded 1. The only downside is that it means one extra database query (functions likeget_main_network_id()appear to be accessing some kind of cache, or perhaps are falling back to default, and only return 1).