WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

#10837 closed enhancement (fixed)

Add *_user_meta() functions

Reported by: scribu Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch early
Focuses: Cc:

Description

Since we have a new generic meta API, we should use it on user metadata too.

Also, the old *_usermeta() functions should be deprecated at some point.

Attachments (3)

user.php.diff (2.9 KB) - added by scribu 5 years ago.
10837-2.diff (9.6 KB) - added by technosailor 4 years ago.
Updates patch to 3.0. Also deprecates old *_usermeta functions in exchange for new *_user_meta() functions that use new metadata API.
10837-3.diff (19.5 KB) - added by technosailor 4 years ago.
Eats our own dog food patch

Download all attachments as: .zip

Change History (24)

scribu5 years ago

comment:1 scribu5 years ago

Related: #7540, #10327

comment:2 scribu5 years ago

  • Type changed from defect (bug) to enhancement

comment:3 scribu5 years ago

Also related: #9065

comment:4 ryan4 years ago

  • Keywords early added
  • Milestone changed from 2.9 to 3.0

Good for early 3.0.

comment:5 ryan4 years ago

Can we switch some places in core to use this so we're eating our own dogfood when this goes in?

comment:6 ramiy4 years ago

  • Cc ramiy added

scribu, change the phpDoc to v3.0.

comment:7 hakre4 years ago

Replying to ramiy:

scribu, change the phpDoc to v3.0.

comitter can do when commit is done.

comment:8 sirzooro4 years ago

  • Cc sirzooro added

comment:9 follow-up: arena4 years ago

Hi all,

just to let you know,

current code to access usermeta data has the metakey value changed by the following code :

$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);

so meta_key such as 'manage-edit-comments-columns-hidden'

is stored as 'manageeditcommentscolumnshidden'

  • i believe this is why usermeta has not been changes in 2.9 .
  • patch should still change metakey value for compatibility with existing datas.

comment:10 follow-up: arena4 years ago

oh ! and missed this one :

WP Mu has only one usermeta table and a postmeta table per blog ...

so 3.0 still merging WP and WPµ ?

comment:11 in reply to: ↑ 9 scribu4 years ago

Replying to arena:

  • patch should still change metakey value for compatibility with existing datas.

No, it shouldn't. That's why we're adding a new set of functions: so that we don't have to worry about compatibility and be consistent with *_post_meta() functions.

comment:12 in reply to: ↑ 10 scribu4 years ago

Replying to arena:

oh ! and missed this one :

WP Mu has only one usermeta table and a postmeta table per blog ...

so 3.0 still merging WP and WPµ ?

I guess we should wait until after most of the merging with MU is done.

comment:13 technosailor4 years ago

The patch should still be good. The *_user_meta() functions just wrap around the relative *_metadata() functions. Compat with MS installs should be handled transparently downstream and should not block inclusion of this patch here.

comment:14 follow-up: nacin4 years ago

There's only about 60 references to the functions these would cause to be deprecated, so we can probably make the switch pretty easily.

Just a note, there is currently no add_usermeta() function, just update_usermeta().

technosailor4 years ago

Updates patch to 3.0. Also deprecates old *_usermeta functions in exchange for new *_user_meta() functions that use new metadata API.

comment:15 in reply to: ↑ 14 technosailor4 years ago

Replying to nacin:

There's only about 60 references to the functions these would cause to be deprecated, so we can probably make the switch pretty easily.

There's really no reason to update those 60 refs right now if using my patch. The old functions are deprecated and turned into wrappers around the new functions for BC reasons.

comment:16 nacin4 years ago

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

(In [13300]) Introduce *_user_meta() functions, deprecate *_usermeta() family. Fixes #10837 props scribu, technosailor.

technosailor4 years ago

Eats our own dog food patch

comment:17 nacin4 years ago

(In [13311]) Don't use deprecated *_usermeta() functions. Props technosailor fixes #10837

comment:18 TobiasBg4 years ago

I haven't checked or tested this, nor do I need if we should take action, but from this BP Trac report, it sounds as if [13300] could potentially break backward compatibility:
http://trac.buddypress.org/ticket/2048

comment:19 nacin4 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

The old *_usermeta() functions should be backwards compatible.

I'm working on a patch right now to restore the same hooks and return values. If necessary we can return the original function definitions for *_usermeta(). Getting some second eyes on this could help.

comment:20 nacin4 years ago

(In [13326]) Ensure we're back compat with return values and actions in deprecated *_usermeta() family. See #10837

comment:21 nacin4 years ago

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

(In [13329]) Switch over to *_user_meta() syntax. The old get_usermeta() would return a string when only one value was found, get_user_meta() requires $single = true. Fixes #10837

Note: See TracTickets for help on using tickets.