Skip to:
Content

Opened 4 years ago

Closed 4 years ago

#5696 closed enhancement (fixed)

Use get_user_by() for bp_core_get_userid_from_nicename()

Reported by: r-a-y Owned by: boonebgorges
Milestone: 2.1 Priority: normal
Severity: normal Version: 1.5.2
Component: Members Keywords: has-patch commit
Cc:

Description

bp_core_get_userid_from_nicename() (or bp_core_get_userid()) is run on every member profile page and is currently uncached.

Attached patch:

  • switches the direct DB query with get_user_by(), which caches the query when an object cache is enabled
  • returns NULL so it emulates the previous DB query on failure

Attachments (1)

5696.01.patch (2.6 KB) - added by r-a-y 4 years ago.

Download all attachments as: .zip

Change History (4)

@r-a-y
4 years ago

#1 @boonebgorges
4 years ago

  • Owner set to boonebgorges
  • Status changed from new to assigned

Thumbs up from me. Removing SQL queries FTW :)

#2 @DJPaul
4 years ago

  • Keywords commit added

Looks good

#3 @r-a-y
4 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 8532:

Use get_user_by() for bp_core_get_userid_from_nicename() and bp_core_get_userid()

Previously, these functions used direct DB queries to grab the user ID when
a user_nicename or user_login was passed.

This commit switches these direct DB queries to use get_user_by(), which
caches the query when a persistent object cache is enabled.

Fixes #5696.

Note: See TracTickets for help on using tickets.