Skip to:
Content

BuddyPress.org

Changeset 11252


Ignore:
Timestamp:
11/28/2016 12:07:20 PM (8 years ago)
Author:
djpaul
Message:

xprofile: fix valueless datebox profile fields erroneously returning the unix epoch.

Fixes #7351 (branch 2.7)

Props nickmomrik

Location:
branches/2.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.7/src/bp-xprofile/classes/class-bp-xprofile-field-type-datebox.php

    r11211 r11252  
    591591     */
    592592    public static function display_filter( $field_value, $field_id = '' ) {
     593        if ( ! $field_value ) {
     594            return $field_value;
     595        }
    593596
    594597        // If Unix timestamp.
  • branches/2.7/tests/phpunit/testcases/xprofile/class-bp-xprofile-field.php

    r10877 r11252  
    205205        $this->assertEquals( $new_field_order, $updated_fetched_field->field_order );
    206206    }
     207
     208    /**
     209     * @ticket BP7351
     210     */
     211    public function test_empty_datebox_fields_should_not_return_unix_epoch() {
     212        $user  = $this->factory->user->create( array( 'role' => 'subscriber' ) );
     213        $group = $this->factory->xprofile_group->create();
     214        $field = $this->factory->xprofile_field->create( array(
     215            'field_group_id' => $group,
     216            'type' => 'datebox',
     217        ) );
     218
     219        $old_user = get_current_user_id();
     220        $this->set_current_user( $user );
     221
     222        $value = bp_get_profile_field_data( array( 'user_id' => $user, 'field' => $field ) );
     223        $this->assertEmpty( $value );
     224
     225        $this->set_current_user( $old_user );
     226    }
    207227}
Note: See TracChangeset for help on using the changeset viewer.