[wp-trac] [WordPress Trac] #37687: Multisite - Enormous number of update queries during site creation (user roles)

WordPress Trac noreply at wordpress.org
Thu Aug 7 01:32:34 UTC 2025


#37687: Multisite - Enormous number of update queries during site creation (user
roles)
-------------------------------------------------+-------------------------
 Reporter:  fliespl                              |       Owner:  realloc
     Type:  enhancement                          |      Status:  closed
 Priority:  normal                               |   Milestone:  6.9
Component:  Upgrade/Install                      |     Version:  2.0
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  good-first-bug has-patch has-test-   |     Focuses:  multisite,
  info dev-feedback commit                       |  performance
-------------------------------------------------+-------------------------
Changes (by peterwilsoncc):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"60614" 60614]:
 {{{
 #!CommitTicketReference repository="" revision="60614"
 Upgrade/Install: Reduce number of DB queries populating roles.

 Reduces the number of database queries made when populating roles during
 install/multisite site creation by 344 (347 queries down to 3).

 `populate_roles()` has been modified to prevent an individual database
 query each time a role or capability is added to the `WP_Roles` object.
 Instead the roles option, `{$wpdb->prefix}user_roles` is updated once at
 the end of the function call.

 Introduces a test to ensure that updating the roles option via `WP_Roles`
 and updating the option in the manner now used by `populate_roles()`
 results in the same capabilities been applied to a role.

 Props fliespl, johnjamesjacoby, ocean90, realloc, rishabhwp,
 sainathpoojary, sirlouen, spacedmonkey, swissspidy.
 Fixes #37687.
 }}}

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


More information about the wp-trac mailing list