perf: lazy-load the top My Sites toolbar and defer initial site-list hydration
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, php, wordpress
- Área
- backend, frontend, performance, testing
Línea de trabajo
Start by inspecting the installed WordPress implementations of WP_Admin_Bar::initialize(), get_blogs_of_user() and wp_admin_bar_my_sites_menu(), then trace the toolbar and filtering paths in inc/managers/class-site-manager.php and magic-link rewriting in inc/sso/class-admin-bar-magic-links.php. Review the named Site Manager and SSO tests and the My Networks implementation reference before changing the scoped files. Done means bounded authenticated pagination, working navigation and fallbacks, preserved permissions and SSO behavior, updated DESIGN.md, and the listed scoped checks and runtime measurements.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What
Lazy-load the top WordPress My Sites toolbar dropdown beside My Networks so an unopened menu does not enumerate and hydrate the full site list or construct every site's management links. This is not the bottom-right Toolbox/Jumper UI.
Keep current-site navigation and an explicit full My Sites administration link immediately available. Fetch bounded, paginated results only when the menu is opened or explicitly requested, preserving the existing site visibility rules, permissions and SSO/magic links.
Why / measured evidence
Read-only authenticated local Users-request profiling, with the My Networks lazy-loading change already served:
| Region | Typical local elapsed | SQL queries | Blog-context events |
|---|---|---|---|
| Initial Ultimate Multisite site-list preparation | 0.166–0.204s | 113 | 58 |
| WordPress My Sites submenu construction | 0.120–0.130s | 22 | 60 |
| Combined initial preparation plus menu | 0.2867s median across 3 runs | 135 | 118 |
Events count both switches and restores, not 118 distinct sites. Later site-list calls were already largely request-cached and added no SQL. The bottom Toolbox setup/render cost about 4ms and no additional SQL on the same request; do not optimize that unrelated UI for this issue.
These are inclusive instrumented CLI request-attribution measurements, not production HTTP savings. One additional run was substantially slower with identical operation counts, so do not promise a fixed latency reduction. Persistent Redis was disabled locally. Verify with controlled HTTP runs after implementing.
Root cause and verified files
inc/managers/class-site-manager.php:1158-1277,hide_customer_sites_from_super_admin_list(): builds up to 40 site objects plus the main site. Reads of$site->blognameand$site->siteurlhydrate WordPress site details and activate downstream blog-switch hooks.inc/managers/class-site-manager.php:1280-1362,is_frontend_my_sites_toolbar_request()andget_current_site_for_frontend_my_sites_toolbar(): existing opt-in, frontend-only, direct-toolbar-initialization optimization is a reference pattern. It intentionally excludes admin/AJAX/REST/CLI and protects nestedget_active_blog_for_user()calls. Do not simply remove those guards.inc/sso/class-admin-bar-magic-links.php: existing My Sites node rewriting must remain effective for lazily loaded links.tests/WP_Ultimo/Managers/Site_Manager_Test.php: existing toolbar context, filtering, user scope and archived/spam/deleted tests.tests/WP_Ultimo/SSO/Admin_Bar_Magic_Links_Test.php: existing magic-link coverage.DESIGN.md: record the changed interaction and fallback behavior.
Reference the WordPress core WP_Admin_Bar::initialize() / get_blogs_of_user() preparation path and wp_admin_bar_my_sites_menu() separately. Deferring just the submenu callback leaves the initial 113-query hydration cost intact. Core lives in the WordPress installation, not in this plugin repository; inspect its installed implementation rather than guessing repository paths.
Use the existing site manager for the authenticated endpoint and add assets/js/my-sites-toolbar.js for the native toolbar controller, following existing asset conventions. If investigation requires a different write surface, record and validate the amended scope before editing. Related implementation reference: Ultimate-Multisite/ultimate-multisite-multinetwork#63, which lazy-loads My Networks with pagination, nonce checks, retry and keyboard/touch support. It is a reference, not an implementation dependency or an assumption that the PR has merged.
Files Scope
inc/managers/class-site-manager.phpinc/sso/class-admin-bar-magic-links.php- NEW:
assets/js/my-sites-toolbar.js tests/WP_Ultimo/Managers/Site_Manager_Test.phptests/WP_Ultimo/SSO/Admin_Bar_Magic_Links_Test.phpDESIGN.md
Bounded implementation contract
- Restrict the lightweight initial site-list behavior to the direct toolbar initialization context; do not globally change
get_blogs_of_user()for profile links, dashboards, admin screens, REST clients or application code. - Preserve existing allowed-site filtering and current-user context. The lazy endpoint must be authenticated, nonce-protected and server-authorized. Do not expose unrelated sites, globally cache capability decisions, or weaken authorization.
- Return at most 10–20 sites per fetch, with deterministic ordering and explicit pagination. Do not preload the complete list in script localization or hidden HTML.
- Preserve network/site-specific URLs, customer-owned-site visibility semantics, existing
get_blogs_of_userfilters and magic-link/SSO behavior. Restore any switched context in afinallyblock. - Retain current-site and full-list navigation without JavaScript. Support hover, keyboard focus and touch; provide loading, empty and explicit retry states, no duplicate in-flight requests, and no focus theft on hover.
- Cover admin and frontend toolbar paths. Do not modify WordPress core or unrelated installed plugins. Do not enable the existing frontend optimization setting globally as a substitute for this implementation.
Acceptance / verification
- Unopened toolbar does not perform full managed-site enumeration/detail hydration or per-site submenu construction.
- Opening the menu fetches only a bounded page; load-more results are disjoint and full-list access remains available.
- Verify current-site navigation and generated links under both subdomain and subdirectory multisite, mapped domains and secondary networks where available.
- Preserve permission denial, customer/non-super-admin behavior, site-state filtering and magic-link behavior. No cross-user/site information disclosure.
- Keyboard activation, Escape/focus return, touch layout, failed-request retry and JavaScript-disabled fallback work in the real rendered product.
- Existing affected Site_Manager and Admin_Bar_Magic_Links suites pass, with only narrow new boundary coverage; no new test runner/harness is needed.
- Run scoped PHPCS/ESLint/PHPStan and inspect standard PHP/browser errors.
- Repeat authenticated HTTP before/after benchmarks with identical user pagination, revisions and cache configuration. Record actual HTTP time separately from CLI attribution; count both scalar and bulk cache-key reads and actual backend calls separately.
- Do not claim the 0.5-second target is reached without runtime evidence. Do not merge or deploy as part of worker implementation without the normal authorized lifecycle.
Rollback: revert the isolated lazy-toolbar change to restore the existing eager menu; no persistent data migration is required.
Pre-flight and routing
- Memory recall: My Sites toolbar/cache performance query returned no relevant stored lessons; current-session runtime evidence is supplied above.
- Discovery: scoped recent-commit, merged-PR, open-PR and claimed-issue searches returned no matching work. Additional open searches for My Sites performance/toolbar returned no matches.
- File references: the five implementation/test/design paths above were verified as tracked; line numbers reflect the inspected revision and must be rechecked at worker pickup.
- Tier:
tier:standard— existing authorization patterns within a defined toolbar-only boundary; not a mechanical exact-edit task. - Seeded draft PR: skipped; preserve the measured finding without anchoring a worker to an unverified patch.
Leaf implementation task. Dispatch: #auto-dispatch. Create a focused implementation PR referencing this issue; no release or deployment is requested.
- Lenguaje dominante
- PHP
- Estrellas
- 218
- Forks
- 87
- Merge medio
- 1 d 7 h
- PR fusionados (30 d)
- 85
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Ultimate-Multisite/ultimate-multisite
-
Secondary networks: sunrise queries unregistered scoped tables, and wu_{N}_* tables are never createdPosiblemente ocupada @superdav42 la tomó hace 3 días. Abiertobug origin:interactive status:in-review
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Ultimate-Multisite/ultimate-multisite#2012 · 13 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Secondary networks never get Ultimate Multisite tables created or upgradedPosiblemente ocupada @superdav42 la tomó hace 5 días. Abiertobug origin:interactive status:claimed
Ultimate-Multisite/ultimate-multisite#2009 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
needs-maintainer-review review:approve
Dificultad 3/5 1-2 días Aptitud para principiantes 62/100
Ultimate-Multisite/ultimate-multisite#1952 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
auto-dispatch needs-investigation origin:worker security status:available tier:standard type:bug
Dificultad 3/5 Medio día Aptitud para principiantes 30/100
Ultimate-Multisite/ultimate-multisite#1938 ·
Los mantenedores suelen responder en 1 día
-
auto-dispatch needs-investigation origin:worker security status:available tier:standard type:bug
Dificultad 3/5 Medio día Aptitud para principiantes 30/100
Ultimate-Multisite/ultimate-multisite#1930 ·
Los mantenedores suelen responder en 1 día
Todos los issues de Ultimate-Multisite/ultimate-multisite
Issues similares
-
type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
flarum/framework#5301 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Add TuneIn-DirMon in the bot listPosiblemente ocupada @liviuconcioiu la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
matomo-org/device-detector#8424 ·
Los mantenedores suelen responder en 1 día
-
An improved changelogAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 63/100
Los mantenedores suelen responder en 1 día
-
affecting 5.2 only affecting 5.3 only bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
moodle-an-hochschulen/moodle-theme_boost_union#1463 ·
Los mantenedores suelen responder en 1 día
-
Course help wanted Sensei
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100