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

WordPress Trac noreply at wordpress.org
Wed Jul 25 16:08:30 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 jeremyfelt):

 Some notes after going through [attachment:"40364.11.diff"]. (I tried
 40364.12.diff, but the patch broke unit tests and I was on a plane, so I
 went back one rev)

 * A domain is required, but only by default through the
 `wp_validate_site_data()` function. If somebody unhooked this default
 validation, then it would be possible to enter domain/path as empty
 strings. This is also possible in the existing `insert_blog()`, so it’s
 probably not a thing to fix, but a thing to remember. Because of this, we
 may want to remove the note in the docs that domain is required or should
 be provided and leave that up to the validation documentation.
 * Why `$validity` instead of `$errors`? The latter seems to be the pattern
 we’ve followed in the past except for the Customizer.
 * I believe it’s possible to insert a site with network ID `0` now. I’m
 not sure if that’s something that somebody is or should be relying on. In
 the current patch, anything passed as `0` will be overwritten with the
 current network ID, even if somebody removed the default site validation
 and added their own.
 * Should we provide protection for anyone inserting a site with a network
 ID that does not exist? I lean toward no, and we may have talked about it
 before. This is probably something to document in the dev note.
 * Should it be possible to delete the main site with `wp_delete_site()` by
 default? I know this is purely transactional, but this can have some
 serious consequences and may be worth some sort of validation that can be
 disabled.
 * It’s a little strange that I can delete sites that still have other
 database tables. It’s also a little strange that I can delete all sites
 and leave myself in a weird place. That does seem like developer
 education, but could there be room for a check that says you can’t delete
 the last site?
 * If a site already exists in the database with a zero date—possibly
 entered through another source (?), I’m not able to update through
 `wp_update_site()` without also including `registered` and `last_updated`
 parameters. I think we need to account for that.
 * Should there be an error when you attempt to update the `blog_id` of a
 site through args passed to `wp_update_site()`? Right now everything
 updates except for the `blog_id`, which may (?) be somewhat confusing.
 * If I use `wp_delete_site( 0 )`, the current site is deleted, which will
 probably lead to trouble somewhere someday. We should have an empty check
 on the ID so that the current site is not grabbed via `get_site()` in that
 scenario. The same thing should probably be done on `wp_update_site()` as
 well to avoid accidental site updating. I don’t think it’s safe to
 fallback in any empty scenario—a site ID should always be provided.

 Thanks for all of the work on this!

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


More information about the wp-trac mailing list