Skip to content

Profiles: Cache user badge lookups#684

Closed
dd32 wants to merge 1 commit into
WordPress:trunkfrom
dd32:issue/2214-cache-user-badges
Closed

Profiles: Cache user badge lookups#684
dd32 wants to merge 1 commit into
WordPress:trunkfrom
dd32:issue/2214-cache-user-badges

Conversation

@dd32
Copy link
Copy Markdown
Member

@dd32 dd32 commented Jun 8, 2026

Splits the badge lookup cache change out of #677 so the support badge PR can stay focused.\n\nThis caches get_user_badges() in the existing user_meta cache group with a namespaced per-user key, and clears that cached badge list when badge group membership changes through the Profiles association handler.\n\nSee https://meta.trac.wordpress.org/ticket/2214.

Copilot AI review requested due to automatic review settings June 8, 2026 03:38
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 8, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props dd32.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces object-caching for Profile badge lookups (get_user_badges()) and ensures that cached badge data is invalidated when badge group membership changes via the Profiles association handler, reducing repeated DB queries for frequently-accessed badge data.

Changes:

  • Cache get_user_badges() results in the user_meta object-cache group under a per-user, namespaced key.
  • Invalidate the per-user badge cache when users are added to / removed from badge groups via the association handler.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
wordpress.org/public_html/wp-content/mu-plugins/pub/profile-helpers.php Adds per-user caching for get_user_badges() lookups using a namespaced cache key.
profiles.wordpress.org/public_html/wp-content/plugins/wporg-profiles-association-handler/wporg-profiles-association-handler.php Clears the per-user badge cache when badge group membership is modified through association requests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wordpress.org/public_html/wp-content/mu-plugins/pub/profile-helpers.php Outdated
@dd32 dd32 force-pushed the issue/2214-cache-user-badges branch from 0c8277e to d9a902b Compare June 8, 2026 03:48
Caches get_user_badges() in the user_meta cache group for one hour and clears the per-user badge cache when badge group membership changes. See https://meta.trac.wordpress.org/ticket/2214.
Copilot AI review requested due to automatic review settings June 8, 2026 04:52
@dd32 dd32 force-pushed the issue/2214-cache-user-badges branch from d9a902b to 075135f Compare June 8, 2026 04:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@bazza bazza closed this in b4406bc Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants