[wp-trac] [WordPress Trac] #37687: Multisite - Enormous number of update queries during site creation (user roles)
WordPress Trac
noreply at wordpress.org
Mon Jun 9 00:02:57 UTC 2025
#37687: Multisite - Enormous number of update queries during site creation (user
roles)
-------------------------------------------------+-------------------------
Reporter: fliespl | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Future
| Release
Component: Networks and Sites | Version:
Severity: normal | Resolution:
Keywords: good-first-bug has-patch has-test- | Focuses: multisite,
info | performance
-------------------------------------------------+-------------------------
Changes (by SirLouen):
* keywords: good-first-bug has-patch needs-test-info => good-first-bug
has-patch has-test-info
Comment:
== Test Report V2
=== Description
✅ This report validates that the indicated patch works as expected.
Patch tested: https://github.com/WordPress/wordpress-
develop/pull/8341.diff
=== Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.28
- Server: nginx/1.27.5
- Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
- Browser: Chrome 137.0.0.0
- OS: Windows 10/11
- Theme: Twenty Twenty-Five 1.2
- MU Plugins: None activated
- Plugins:
* MS Site Creation Query Tracker 1.0.0
* Test Reports 1.2.0
=== Test Reproduction Steps
1. Activate Multisite
2. Install my Plugin: https://raw.githubusercontent.com/SirLouen/ms-site-
creation-tracker/refs/tags/1.0.0/ms-site-creation-tracker.php
3. Go to Network Admin > Sites > Site Tracker
4. Add a new site
5. By default, it's reporting 545 queries
=== Expected Results
1. There are many unnecessary queries because each single `add_role` and
`add_cap` inside the `populate_roles` executes a query only if the `wp_db`
property is set to `true`
2. Verify if the record in `wp_x_options` -> `wp_X_user_roles` (being X
the site id, before and after the patch) is identical before and after the
patch.
=== Actual Results
1. ✅ Issue resolved with patch: Reporting, by default, 201 queries
2. ✅ Roles creation are identical pre and post patch.
=== Additional Notes
- After [https://core.trac.wordpress.org/ticket/37687#comment:7 my first
report], I wasn't very satisfied with the result by using the Query
Monitor Plugin, so I put this on my backlog to make a little plugin for
further testing. On the paper this report made all sense, but I was unable
to reproduce it, so I was uncertain of what was going on, maybe `wp_db`
was being disabled at some other point or something 🤷♂️. Now with my
plugin, I've been able to clearly verify the problem and confirm the
hypothesis.
=== Supplemental Artifacts
Link to test plugin Repo: https://github.com/SirLouen/ms-site-creation-
tracker
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37687#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list