WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#23192 closed enhancement (fixed)

Use get_user_by() in is_user_spammy()

Reported by: ocean90 Owned by: SergeyBiryukov
Milestone: 3.6 Priority: normal
Severity: normal Version:
Component: Multisite Keywords: has-patch commit needs-unit-tests
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Comes up after reading #23190.

Since is_user_spammy expects a user name, we should replace get_user_id_from_string( $username ) with get_user_by( 'login', $username ). Same for the id.

Attachments (3)

23192.patch (826 bytes) - added by ocean90 3 years ago.
23192-ut.patch (767 bytes) - added by bananastalktome 3 years ago.
23192.1.patch (1.0 KB) - added by bananastalktome 3 years ago.
also update function inline docs to reflect change

Download all attachments as: .zip

Change History (11)

@ocean903 years ago

comment:1 @ocean903 years ago

  • Keywords has-patch added

comment:2 @SergeyBiryukov3 years ago

  • Description modified (diff)
  • Keywords 2nd-opinion removed
  • Milestone changed from Awaiting Review to 3.6

I agree. We could then deprecate get_user_id_from_string(), since it's the only instance in core.

comment:3 @SergeyBiryukov3 years ago

  • Keywords commit added

comment:4 @ryan3 years ago

  • Keywords needs-unit-tests added

Looks good. Let's add some simple unit tests.

comment:5 @bananastalktome3 years ago

  • Cc bananastalktome@… added

Does this test look sufficient?

@bananastalktome3 years ago

@bananastalktome3 years ago

also update function inline docs to reflect change

comment:6 @SergeyBiryukov3 years ago

In 1216/tests:

Test that is_user_spammy() properly recognizes a numeric username. props bananastalktome. see #23192. see #23190.

comment:7 @SergeyBiryukov3 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 23431:

Replace get_user_id_from_string() with get_user_by(). props ocean90, bananastalktome. fixes #23192. see #23190.

comment:8 @SergeyBiryukov3 years ago

In 23432:

Use wp_get_current_user(). props nacin. see #23192.

Note: See TracTickets for help on using tickets.