Skip to:

Opened 9 years ago

Closed 9 years ago

#6082 closed defect (bug) (fixed)

Incorrect results from xprofile_get_field_id_from_name( $field_name )

Reported by: dontdream's profile dontdream Owned by: r-a-y's profile r-a-y
Milestone: 2.2 Priority: normal
Severity: normal Version: 2.1
Component: Extended Profile Keywords: has-patch needs-unit-tests


When a field name and an option value are the same, the function

xprofile_get_field_id_from_name( $field_name )

may return the option ID instead of the desired field ID.

The attached patch restricts the search to rows with parent_id = 0.

Attachments (1)

6082.patch (712 bytes) - added by dontdream 9 years ago.

Download all attachments as: .zip

Change History (4)

9 years ago

#1 @dontdream
9 years ago

  • Keywords has-patch added

#2 @boonebgorges
9 years ago

  • Keywords needs-unit-tests added
  • Milestone changed from Awaiting Review to 2.2

Good find. Let's get a unit test for it.

#3 @r-a-y
9 years ago

  • Owner set to r-a-y
  • Resolution set to fixed
  • Status changed from new to closed

In 9324:

XProfile: Make sure xprofile_get_field_id_from_name() returns a field ID for a field name.

Previously, when using xprofile_get_field_id_from_name(), it was possible
to get the option ID instead of the desired field ID because a field name
and an option value (for a checkbox or radio field) can potentially be the
the same in the wp_bp_xprofile_fields DB table.

This commit ensures that field name look ups will return a field ID instead
of an option ID. Commit also includes a unit test.

Props dontdream.

Fixes #6082.

Note: See TracTickets for help on using tickets.