Conversation
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
🟡 Changes recommended
Both routines still scan all users and load metadata for the entire user set.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 2
Open (2)
What changed in this PR
This PR optimizes theme-switch cleanup by retrieving user IDs and priming metadata instead of loading full user objects.
Changes:
- Updates both notice cleanup routines.
- Uses ID-only user queries.
- Bulk-primes user metadata before deletion.
| File | Summary |
|---|---|
inc/admin/class-spacious-theme-review-notice.php |
Optimizes theme-review notice cleanup; the query remains unbounded. |
inc/admin/class-spacious-tdi-notice.php |
Optimizes importer notice cleanup; the query remains unbounded. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+74
to
+78
| $user_ids = get_users( array( 'fields' => 'ID' ) ); | ||
|
|
||
| foreach ( $get_all_users as $user ) { | ||
| $ignored_notice = get_user_meta( $user->ID, 'ignore_spacious_tdi_notice', true ); | ||
| // Fetching IDs only skips core's own cache_users() priming, so prime | ||
| // it ourselves - one query for every user's meta instead of one per user. | ||
| update_meta_cache( 'user', $user_ids ); |
Comment on lines
+196
to
+206
| $user_ids = get_users( array( 'fields' => 'ID' ) ); | ||
| $theme_installed_time = get_option( 'spacious_theme_installed_time' ); | ||
|
|
||
| // Delete options data. | ||
| if ( $theme_installed_time ) { | ||
| delete_option( 'spacious_theme_installed_time' ); | ||
| } | ||
|
|
||
| // Fetching IDs only skips core's own cache_users() priming, so prime | ||
| // it ourselves - one query for every user's meta instead of two per user. | ||
| update_meta_cache( 'user', $user_ids ); |
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.

Changes proposed in this Pull Request:
Fixes the same issue as themegrill/spacious-pro#41, which was also filed against this free theme. When you switch away from Spacious to a different theme, two separate cleanup routines run to clear leftover notice-dismissal settings (one for the demo importer notice, one for the "please review this theme" notice). Both were fetching every single user account on the site as a full object, just to check one or two small settings for each of them. On a site with a large number of user accounts, this made switching themes unnecessarily slow. This fix makes both cleanups happen in a much lighter way, with no change in what actually gets cleaned up.
Note: the second routine (the theme-review notice cleanup) was not named in the original issue report, but has the identical pattern and is fixed here for the same reason.
How to test the changes in this Pull Request:
Types of changes:
Other information:
Changelog entry
Fix - Unbounded get_users() full-table scan in theme-switch cleanup.