Conversation
… theme switch review_notice_data_remove() called get_users() with no arguments, which builds a user object and loads the meta for every user just to find the few who dismissed the notice. It now asks only for the IDs of users who have each flag and deletes it for those, scoped to the current site as before. Verified with 131 users: peak extra memory dropped from about 1.7 MB to about 0.5 MB with the same number of queries when users are flagged; all flagged rows are removed and other meta is left alone.
QA suite — refused, no regression specThis PR changes product source but adds no spec, so the suite was Source files changed with no matching spec |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Optimizes theme-switch cleanup by querying only users with review-notice dismissal metadata instead of loading every user.
Changes:
- Targets matching user IDs for cleanup.
- Preserves site scope and option cleanup.
- Leaves unrelated user metadata untouched.
| File | Summary |
|---|---|
inc/admin/class-accelerate-theme-review-notice.php |
Uses targeted user-ID queries for notice metadata cleanup. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Free-theme counterpart of themegrill/accelerate-pro#26 (the same pattern is in the free review notice).
Changes proposed in this Pull Request:
On
switch_theme,review_notice_data_remove()calledget_users()with no arguments, which builds aWP_Userobject and loads the meta for every user, only to find the few who dismissed the review notice. It now asks for just the IDs of users that have each flag (accelerate_ignore_theme_review_noticeandnag_accelerate_ignore_theme_review_notice_partially) and deletes it for those. It is still limited to the current site's users, as before. Theaccelerate_theme_installed_timeoption cleanup is unchanged.The issue says there is no GitHub repo for the free theme, but this one exists. It also estimates two queries per user; WordPress primes the user meta cache in bulk inside
get_users(), so the real cost is memory and object building, not per-user queries. I did not use the suggesteddelete_metadata( 'user', 0, $key, '', true )because user meta is shared across a multisite network, so it would clear the flags for users on every site, not just the current one.Measured on a local site with 131 users (a temporary mock, since removed):
PHPCS on the changed file shows no new violations (3 to 2 errors). The new
meta_keylookup carries a one-linephpcs:ignorewith the reason: it is indexed and runs once per theme switch.How to test the changes in this Pull Request:
usermetatable: noaccelerate_ignore_theme_review_noticeornag_accelerate_ignore_theme_review_notice_partiallyrows remain, and other user meta is unchanged.Types of changes:
Other information:
Changelog entry
Fix - Theme switch no longer loads every user to clear dismissed notice flags.