[wp-trac] [WordPress Trac] #50324: Can't create new blog in multisite if database insert happens on clean_site_cache
WordPress Trac
noreply at wordpress.org
Fri Jun 5 01:06:46 UTC 2020
#50324: Can't create new blog in multisite if database insert happens on
clean_site_cache
--------------------------------+-----------------------------
Reporter: trepmal | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Networks and Sites | Version: 5.3
Severity: normal | Keywords:
Focuses: multisite |
--------------------------------+-----------------------------
In multisite, you cannot create a new blog if there is a database insert
happening on the `clean_site_cache` action.
Introduced in r45910
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/ms-
site.php#L68-L74
On L68, the blog data is inserted into the blogs table. The new blog ID is
in `$wpdb->insert_id`. This ID is then needed shortly after at L74 to get
the WP_Site object.
However, `clean_blog_cache()` has an action hook. If something hooked in
there does a database insert, the value of `$wpdb->insert_id` changes.
This is likely to cause a `Could not retrieve site data.` but there are
some other scenarios:
- If `$wpdb->insert_id` does not match any blog ID: `Error: Could not
retrieve site data.`
- If `$wpdb->insert_id` matches a valid blog: potentially perform actions
against the wrong blog. Anything run on wp_initialize_site will run
against the preexisting blog, not the newly created one.
- If `$wpdb->insert_id` matches a half-installed blog (such as from case
1): The original blog will be fully installed since L74 now returns
truthy. However, there will be some mixed values (`home`/`siteurl` will
match wp_blogs values of older site, `blogname` will match the newly
created blog.)
- If `$wpdb->insert_id` matches by pure chance the correct blog_id: Task
failed successfully.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50324>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list