[wp-trac] [WordPress Trac] #40364: Improve site creation in multisite

WordPress Trac noreply at wordpress.org
Wed Jun 13 09:25:04 UTC 2018


#40364: Improve site creation in multisite
-------------------------------------------------+------------------------
 Reporter:  jeremyfelt                           |       Owner:  flixos90
     Type:  enhancement                          |      Status:  assigned
 Priority:  normal                               |   Milestone:  5.0
Component:  Networks and Sites                   |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  ms-roadmap has-patch has-unit-tests  |     Focuses:  multisite
-------------------------------------------------+------------------------

Comment (by flixos90):

 [attachment:40364.9.diff] is has a few improvements over the previous
 patch:

 * Introduce a `wp_normalize_site_data` filter to normalize the data passed
 to `wp_insert_site()` and `wp_update_site()`. This reduces complexity of
 the functions significantly and reduces duplicate code. A function
 `wp_normalize_site_data()` is automatically hooked in for default
 normalization (stripping invalid characters from domain, ensuring the path
 has a trailing slash, maintaining BC when someone uses `site_id` instead
 of `network_id`).
 * Rename `validate_site_data` action to `wp_validate_site_data`.
 * In `wp_validate_site_data()`, ensure that the path is not empty.
 * In `wpmu_create_blog()`, pass the data in the `$meta` array that is
 relevant for the `wp_blogs` row to `wp_insert_site()` immediately.
 `insert_blog()` didn't support those, but our new function does, so we can
 reduce database transactions by quite a few here. Afterwards these values
 can be removed from the `$meta` array, since it should only contain
 regular options at this point.
 * Ensure `wp_maybe_transition_site_statuses_on_update()` is hooked into
 `wp_insert_site` as well. In that case, the default flag values for a site
 are used to compare against. This ensures that the site status hooks fire
 also when inserting a site as necessary, which would previously happen
 because `update_blog_status()` was called for each flag. This ensures that
 the change in `wpmu_create_blog()` described above is fully backward-
 compatible.
 * In `wpmu_create_blog()`, temporarily unhook the action to change the
 `blog_public` option. This needs to happen because at this point the
 database tables are not available yet. We will be able to remove this hack
 once #41333 is done, since that will hook in the site installation process
 before that hook.

 With just a few more unit tests, this should be ready to go in.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/40364#comment:47>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list