#23400 closed defect (bug) (fixed)
insert_blog() can possible return the wrong blog id when plugin/theme uses refresh_blog_details action
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.6 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Multisite | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
The function insert_blog() returns $wpdb->insert_id after calling refresh_blog_details(). So if a plugin or theme is using the refresh_blog_details action and does something that changed $wpdb, the returned blog id will be wrong and WordPress creates table names with the wrong id in their name.
I understand if this isn't considered a bug. But I've attached a suggested patch anyway. I think it would be good.
Attachments (2)
Change History (8)
#3
@
12 years ago
I uploaded insert-blog-bug.php that is a plugin that duplicates the error.
Warning
Only run this on a clean install. To duplicate the error I truncate wp_posts and then changes the auto increment value to 100. This way, when a post is inserted it gets id 100 and the error is shown with insert_blog() returning 100 instead of the newly created actual blog id 2.
Test it by creating a multi site install and then visiting http://your-test-site.com/?action=testbug - It will output "Created blog id: 100" if the bug was visible. If there is an error the WP_Error object us output using var_dump().
This is a screenshot of my tables after running the plugin.
This is a screenshot of the Sites panel in network admin.
Running it will my patch creates everything ok.
#4
@
12 years ago
- Type changed from enhancement to defect (bug)
Looks proper from here too, and for what it's worth, definitely a bug.
Looks proper to me.