Skip to:
Content

BuddyPress.org

Opened 4 years ago

Closed 4 years ago

#6443 closed defect (bug) (fixed)

Cannot have "0" as XProfile field option

Reported by: johnjamesjacoby Owned by:
Milestone: 2.3 Priority: normal
Severity: normal Version: 2.2
Component: Extended Profile Keywords: has-patch
Cc:

Description

If you try to create an XProfile field option with the name "0" the following error will occur:

'This field type requires at least one option. Please add options below.'

Attachments (1)

6443.01.patch (715 bytes) - added by johnjamesjacoby 4 years ago.

Download all attachments as: .zip

Change History (6)

#1 @johnjamesjacoby
4 years ago

6443.01.patch uses isset() rather than empty() in BP_XProfile_Field::admin_validate().

#2 @johnjamesjacoby
4 years ago

Same goes for fields; they cannot be named "0" due to an empty() check in the same method.

#3 @johnjamesjacoby
4 years ago

In 9878:

XProfile: Add tests for "0" field names and field options. See #6443.

#4 @johnjamesjacoby
4 years ago

In 9879:

XProfile: Improve field validation in BP_Profile_Field::admin_validate().

  • Break inline conditions apart into multiple specific ones to improve logical flow of field validation
  • Introduce more helpful $message feedback for each new condition, including the field-type name where possible
  • Replace empty() checks with ! isset() to allow "0" values as names and options
  • Remove field_file check, as the "file" field type was removed when avatar uploads were refactored in 1.0
  • Much more appropriate field-option validation using sanitize_text_field to
  • Properly escape gettext output
  • Tests introduced in r9878

See #6443.

#5 @johnjamesjacoby
4 years ago

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

This is complete.

Note: See TracTickets for help on using tickets.