Skip to:
Content

BuddyPress.org

Changeset 8554


Ignore:
Timestamp:
06/28/2014 06:23:15 PM (9 years ago)
Author:
djpaul
Message:

xProfile: fix profile fields not rendering if their value is "0".

This was caused by a reliance on the empty() function in a few places, which was causing us to
not handle "0" (both as int and string) as a valid field value. In turn, this was causing the
profile field template loop to skip rendering the affected field.

Fixes #5731, props DJPaul and r-a-y.

Location:
trunk/src/bp-xprofile
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/bp-xprofile-classes.php

    r8547 r8554  
    228228                    // Empty fields may contain a serialized empty array
    229229                    $maybe_value = maybe_unserialize( $data->value );
    230                     if ( !empty( $maybe_value ) && false !== $key = array_search( $data->field_id, $field_ids ) ) {
     230
     231                    // Valid field values of 0 or '0' get caught by empty(), so we have an extra check for these. See #BP5731
     232                    if ( ( ! empty( $maybe_value ) || '0' == $maybe_value ) && false !== $key = array_search( $data->field_id, $field_ids ) ) {
     233
    231234                        // Fields that have data get removed from the list
    232235                        unset( $field_ids[$key] );
  • trunk/src/bp-xprofile/bp-xprofile-filters.php

    r8547 r8554  
    128128 */
    129129function xprofile_filter_format_field_value( $field_value, $field_type = '' ) {
    130     if ( !isset( $field_value ) || empty( $field_value ) )
     130    // Valid field values of 0 or '0' get caught by empty(), so we have an extra check for these. See #BP5731
     131    if ( ! isset( $field_value ) || empty( $field_value ) && '0' != $field_value )
    131132        return false;
    132133
  • trunk/src/bp-xprofile/bp-xprofile-template.php

    r8489 r8554  
    143143        $field = $this->next_field();
    144144
    145         $value = !empty( $field->data ) && !empty( $field->data->value ) ? maybe_unserialize( $field->data->value ) : false;
    146 
    147         if ( !empty( $value ) ) {
     145        // Valid field values of 0 or '0' get caught by empty(), so we have an extra check for these. See #BP5731
     146        if ( ! empty( $field->data ) && ( ! empty( $field->data->value ) || '0' == $field->data->value ) ) {
     147            $value = maybe_unserialize( $field->data->value );
     148        } else {
     149            $value = false;
     150        }
     151
     152        if ( ! empty( $value ) || '0' == $value ) {
    148153            $this->field_has_data = true;
    149154        } else {
Note: See TracChangeset for help on using the changeset viewer.