Skip to content

Fix unbounded get_users() full-table scan in theme-switch notice cleanup - #65

Open
deepench wants to merge 1 commit into
developfrom
fix/unbounded-get-users-notice-cleanup
Open

deepench wants to merge 1 commit into
developfrom
fix/unbounded-get-users-notice-cleanup

Conversation

@deepench

Copy link
Copy Markdown

Related to themegrill/radiate-pro#34 (same root cause, both editions)

Changes proposed in this Pull Request:

Same pattern as Radiate Pro: review_notice_data_remove() ran get_users() with no arguments on every theme switch, loading every site user just to check and delete two per-user meta flags for each. Fixed by querying only user IDs that actually have one of the two meta keys set, via meta_query with relation => OR, and operating on IDs instead of full user objects.

Verified live: created test users, set one of the two notice-dismissal meta keys on each, triggered a genuine admin theme-switch (Appearance > Themes > Activate), and confirmed both users' meta were correctly cleaned up.

Types of changes:

  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (modification of the currently available functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Other information:

  • Have you added an explanation of what your changes do and why you would like us to include them?
  • Have you successfully ran tests with your changes locally?
  • Have you updated the documentation accordingly?

PHPCS: clean, aside from one expected WordPress.DB.SlowDBQuery.slow_db_query_meta_query warning -- the standard, recommended pattern for a targeted usermeta lookup, replacing the far more expensive unconditional full-table load.

Changelog entry

Fix - Theme-switch cleanup no longer loads every site user just to clear notice flags.

@tg-autopilot
tg-autopilot requested a lite review from Copilot September 29, 2026 08:32
@github-actions

Copy link
Copy Markdown

QA suite — refused, no regression spec

This PR changes product source but adds no spec, so the suite was
refused before booting WordPress — running it just to report the same
thing at the end costs runner minutes for nothing. Run
/claudegrill:verify-fix locally and let write-spec add the guard
to this branch, then push again.

Source files changed with no matching spec
inc/admin/class-radiate-theme-review-notice.php

@deepench

Copy link
Copy Markdown
Author

Built theme zip for this branch (fix/unbounded-get-users-notice-cleanup):

radiate-fix-unbounded-get-users-notice-cleanup.zip (built via npm run build)

Upload it via Appearance > Themes > Add New > Upload Theme on a test site.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

This PR optimizes theme-switch cleanup by targeting users with relevant notice metadata instead of loading all users.

Changes:

  • Uses an OR meta query for the two notice flags.
  • Retrieves user IDs only and removes both flags.
File Description
inc/​admin/​class-radiate-theme-review-notice.php Optimizes review-notice metadata cleanup.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@deepench
deepench requested a review from subin-shk September 29, 2026 08:34
@deepench deepench self-assigned this Sep 29, 2026
@deepench deepench added the bug label Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants