Skip to:
Content

BuddyPress.org

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#8494 closed defect (bug) (fixed)

PHP error with WP Biography xProfile field type sanitization callback

Reported by: imath's profile imath Owned by: imath's profile imath
Milestone: 9.0.0 Priority: normal
Severity: normal Version: 8.0.0
Component: Extended Profile Keywords: has-patch
Cc:

Description

When this field is empty, BP_XProfile_Field_Type_WordPress::sanitize_for_db() is generating an error trying to trim an array.

I need to understand why it's not a string as expected 🤔

Attachments (1)

8494.patch (639 bytes) - added by imath 3 years ago.

Download all attachments as: .zip

Change History (5)

@imath
3 years ago

#1 @imath
3 years ago

  • Keywords needs-testing removed

Ok, I got it: xprofile_set_field_data() is using an array for fields accepting a null value (used for checkboxes, multiselect). That's why.

#2 @imath
3 years ago

In 12977:

Make sure saving empty WP xProfile fields does generate an error

WP xProfile field types are allowing their values to be empty. In such a case the xprofile_set_field_data() is using an array as the value to be saved. This is done to avoid the value of certain types of fields (checkboxes, multiselects) to be overwritten by the default value on next edit.

For WP xProfile field types, we simply need to return an empty string in this case.

See #8494 (branch 8.0)

#3 @imath
3 years ago

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

In 12978:

Make sure saving empty WP xProfile fields does generate an error

WP xProfile field types are allowing their values to be empty. In such a case the xprofile_set_field_data() is using an array as the value to be saved. This is done to avoid the value of certain types of fields (checkboxes, multiselects) to be overwritten by the default value on next edit.

For WP xProfile field types, we simply need to return an empty string in this case.

Fixes #8494 (trunk)

#4 @imath
3 years ago

  • Milestone changed from 8.1.0 to 9.0.0

Ticket retargeted after milestone deleted

Note: See TracTickets for help on using tickets.