[wp-trac] [WordPress Trac] #41333: Implement `wp_initialize_site()` and `wp_uninitialize_site()`

WordPress Trac noreply at wordpress.org
Wed Sep 5 14:41:34 UTC 2018


#41333: Implement `wp_initialize_site()` and `wp_uninitialize_site()`
-------------------------------------------------+-------------------------
 Reporter:  flixos90                             |       Owner:  flixos90
     Type:  enhancement                          |      Status:  assigned
 Priority:  normal                               |   Milestone:  5.0
Component:  Networks and Sites                   |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  ms-roadmap has-patch needs-unit-     |     Focuses:  multisite
  tests needs-testing needs-dev-note             |
-------------------------------------------------+-------------------------
Changes (by flixos90):

 * keywords:  ms-roadmap has-patch needs-unit-tests needs-testing dev-
     feedback => ms-roadmap has-patch needs-unit-tests needs-testing needs-
     dev-note


Comment:

 [attachment:"41333.3.diff"] includes the following improvements:

 * In `wp_initialize_site()`, passed `options` are directly passed to
 `populate_options()` for efficient insertion.
 * In `wp_initialize_site()`, a `meta` argument is now supported, as key =>
 value pairs, which are then passed to `populate_site_meta()`.
 * Introduce a `wp_initialize_site_args` filter to adjust arguments passed
 to site initialization on the fly.
 * Introduce a `wp_validate_site_deletion` action, that receives a
 `WP_Error` object and allows to cancel site deletion.
 * Fix a critical bug where sites with an empty user ID would not be
 initialized. This was previously possible and needs to remain that way.
 * Adjust the two utility functions hooked into `wpmu_new_blog` (which is
 deprecated) to be hooked into `wp_initialize_site` instead. A tiny bit of
 code has been adjusted in both functions to support the different types of
 parameters from the new action.

 As of this patch, all existing unit tests pass without issues.

 There are only a few things left to do:

 * Complete #44894, and then add support for custom `roles` to
 `wp_initialize_site()`.
 * Add tests for `wp_initialize_site()`.
 * Add tests for `wp_uninitialize_site()`.
 * Add tests for `wp_is_site_initialized()`.
 * Add tests to ensure `wp_insert_site()` triggers `wp_initialize_site()`
 with proper arguments correctly.
 * Add tests to ensure `wp_delete_site()` triggers `wp_uninitialize_site()`
 correctly.
 * Unhook `wp_initialize_site()` from `wp_initialize_site` for all
 `wp_insert_site()` tests that don't interact with the site's scope at all,
 to significantly improve tests performance.
 * Add tests for the new `wp_validate_site_deletion` action.

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


More information about the wp-trac mailing list