Opened 6 years ago
Closed 6 years ago
#50324 closed defect (bug) (fixed)
Can't create new blog in multisite if database insert happens on clean_site_cache
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 5.5 | Priority: | normal |
| Severity: | normal | Version: | 5.3 |
| Component: | Networks and Sites | Keywords: | has-patch |
| Focuses: | multisite | Cc: |
Description
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_iddoes not match any blog ID:Error: Could not retrieve site data.
- If
$wpdb->insert_idmatches 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_idmatches 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/siteurlwill match wp_blogs values of older site,blognamewill match the newly created blog.)
- If
$wpdb->insert_idmatches by pure chance the correct blog_id: Task failed successfully.
Attachments (3)
Change History (5)
Note: See
TracTickets for help on using
tickets.
patch with test