[buddypress-trac] [BuddyPress] #4109: xprofile_get_field_data not unserializing values

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Fri Apr 6 22:41:43 UTC 2012


#4109: xprofile_get_field_data not unserializing values
-------------------------+------------------
 Reporter:  shanebp      |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  1.6
Component:  XProfile     |     Version:
 Severity:  minor        |  Resolution:
 Keywords:               |
-------------------------+------------------
Changes (by boonebgorges):

 * type:  defect (bug) => enhancement
 * severity:  normal => minor
 * milestone:  Awaiting Review => 1.6


Comment:

 I've had a closer look.

 The issue is not serialization. The value returned by
 `xprofile_get_field_data()` is indeed unserialized; see this line in the
 function:

 {{{
 $values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid(
 $field_id, $user_id ) );
 }}}

 (See http://www.php.net/serialize for more on `serialize()` in PHP)

 What shanebp is pointing toward is that the values returned by
 `xprofile_get_field_data()` are left in an array rather than being
 converted to a comma-separated string. (In contrast,
 `bp_get_the_profile_field_value()` runs its values through
 `bp_unserialize_profile_field()` before returning, which both unserializes
 *and* converts to a comma-separated string.) This is not a regression from
 1.2.x, though there was a bug in this function 1.2.x that actually *was*
 related to serialization.

 In any case, it seems clear that this is not a bug. And it would break
 backward-compatibility if the behavior of this function were changed
 outright. However, I think it's reasonable to add an argument to
 `xprofile_get_field_data()` that will allow you to request a comma-
 separated string instead of a raw array. I'm going to commit such a change
 shortly.

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4109#comment:4>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list