Make WordPress Core

Opened 7 years ago

Closed 3 years ago

Last modified 3 years ago

#43339 closed enhancement (fixed)

Global user_options calls should use user_meta instead

Reported by: johnjamesjacoby's profile johnjamesjacoby Owned by: zkancs's profile zkancs
Milestone: 5.8 Priority: normal
Severity: normal Version:
Component: General Keywords: 2nd-opinion good-first-bug has-patch
Focuses: Cc:

Description

There are 2 places where WordPress uses the user_option functions with the global flag set to true which internally invokes the user_meta functions.

In these cases, there is no benefit to using user_option and only a detriment by way of additional function calls.

The user-meta keys in question are:

  • default_password_nag
  • community-events-location

Attachments (4)

43339.diff (4.8 KB) - added by zkancs 7 years ago.
Use update_user_meta instead of update_user_option
43339.2.diff (4.8 KB) - added by zkancs 7 years ago.
43339.3.diff (10.4 KB) - added by zkancs 7 years ago.
43339.4.diff (8.2 KB) - added by zkancs 7 years ago.

Download all attachments as: .zip

Change History (17)

#1 @obenland
7 years ago

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

@zkancs
7 years ago

Use update_user_meta instead of update_user_option

@zkancs
7 years ago

#2 @obenland
7 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Awaiting Review to 5.0

#3 @obenland
7 years ago

It looks like there are some more instances where update_user_option is used with $global set to true. Doe we want to change those too?

#4 @zkancs
7 years ago

@obenland Yes, I'll change the rest of them.

@zkancs
7 years ago

#5 @zkancs
7 years ago

There're some mistakes in the HTML I've made. Fixing them.

@zkancs
7 years ago

#6 @zkancs
7 years ago

@obenland Fixed. I think I've changed every place where update_user_option is used with $global set to true. Please review again.

#7 @johnbillion
6 years ago

  • Milestone changed from 5.0 to 5.1

#8 @pento
6 years ago

  • Keywords needs-refresh added
  • Milestone changed from 5.1 to Future Release

43339.4.diff needs updating to apply to trunk.

This ticket was mentioned in Slack in #core by jjj. View the logs.


4 years ago

#10 @SergeyBiryukov
4 years ago

  • Milestone changed from Future Release to 5.8

This ticket was mentioned in PR #1244 on WordPress/wordpress-develop by desrosj.


3 years ago
#11

  • Keywords needs-refresh removed

#12 @desrosj
3 years ago

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

In 50981:

General: Avoid unnecessary calls to update_user_option().

The update_user_option() function is a way to update a user meta value after adding a blog’s prefix to the beginning of the meta key. But when the fourth parameter is true, the behavior is exactly the same as calling update_user_meta() directly.

This replaces all instances of update_user_option() when the fourth parameter is true in Core with a direct call to update_user_meta() to prevent an unnecessary call to update_user_option().

Props johnjamesjacoby, zkancs, obenland, desrosj.
Fixes #43339.

Note: See TracTickets for help on using tickets.