Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#14924 closed defect (bug) (fixed)

author/user meta data extraction error

Reported by: iamronen's profile iamronen Owned by:
Milestone: 3.1 Priority: normal
Severity: major Version: 3.0.1
Component: Users Keywords: user, author, meta
Focuses: Cc:

Description

It seems that if user meta data fields are created with dashes '-' then retrieval functions fail. Fields are properly stored in the database but retrieving with "get_the_author_meta" fails.

When I manually changed the field names to underscores '_' they were extracted OK. When I changes them back to dashes '-' they again failed.

Change History (4)

#1 @dd32
14 years ago

using get_user_meta() works as expected.

The cause here is that the User object will store 'test-key' as 'testkey' due to dashes not being allowed in class properties thanks to this code: http://core.trac.wordpress.org/browser/trunk/wp-includes/user.php#L923

#2 @iamronen
14 years ago

I may be missing them - but the code you linked to seems to relate to basic user fields while I was referring to meta data (custom fields that I added) ... if it is as you say - it is an unclear and undocumented inconsistency. I would expect the two functions to behave identically.

#3 @dd32
14 years ago

  • Milestone changed from Awaiting Review to 3.1

Test Code:

update_user_meta(1, 'test-key', 'test');
var_dump( get_the_author_meta('test-key', 1) );
delete_user_meta(1, 'test-key');

Result Before:

string '' (length=0)

Result After:

string 'test' (length=4)

#4 @dd32
14 years ago

  • Component changed from General to Users
  • Resolution set to fixed
  • Status changed from new to closed

[15692] - Sanitize meta keynames used as object properties on retrieval. Fixes #14924

Note: See TracTickets for help on using tickets.