Skip to:
Content

BuddyPress.org

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#4109 closed enhancement (fixed)

xprofile_get_field_data not unserializing values

Reported by: shanebp's profile shanebp Owned by:
Milestone: 1.6 Priority: normal
Severity: minor Version:
Component: Extended Profile Keywords:
Cc:

Description

Not sure if this is a bug, but the 1.5.5 rework of bp-xprofile has this side effect:

http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/bp-1-5-unserialize-profile-field/

Or maybe there was a change to WP is_serialized() ?

Change History (6)

#1 @shanebp
12 years ago

  • Component changed from Core to XProfile

#2 @boonebgorges
12 years ago

the 1.5.5 rework of bp-xprofile

Was there a 1.5.5 rework? Is this a regression from 1.5.4?

#3 @shanebp
12 years ago

Sorry - I meant 1.5.
I'm using 1.5.5

Last edited 12 years ago by shanebp (previous) (diff)

#4 @boonebgorges
12 years ago

  • Milestone changed from Awaiting Review to 1.6
  • Severity changed from normal to minor
  • Type changed from defect (bug) to enhancement

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.

#5 @boonebgorges
12 years ago

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

(In [5962]) Adds multi_format parameter to xprofile_get_field_data(), so that values can be returned in a comma-separated string for easier theming. Fixes #4109

#6 @shanebp
12 years ago

Thanks for the interpretation of my garbled report.
And thanks for the fix.

Note: See TracTickets for help on using tickets.