WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/23/2018 06:55:45 PM (14 months ago)
Author:
danielbachhuber
Message:

Meta: Allow empty strings to be set by Custom Fields meta box.

Because the REST API allows meta keys to have empty values, the Custom Fields meta box should permit the same behavior.

Props charlestonsw, soulseekah.
Fixes #43559.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/tests/phpunit/tests/admin/includesPost.php

    r43762 r43811  
    708708        $this->assertSame( array( 'icon' => 'text' ), $blocks[ $name ] );
    709709    }
     710
     711    /**
     712     * @ticket 43559
     713     */
     714    public function test_post_add_meta_empty_is_allowed() {
     715        $p     = self::factory()->post->create();
     716
     717        $_POST = array(
     718            'metakeyinput' => 'testkey',
     719            'metavalue'    => '',
     720        );
     721
     722        wp_set_current_user( self::$admin_id );
     723
     724        $this->assertNotFalse( add_meta( $p ) );
     725        $this->assertEquals( '', get_post_meta( $p, 'testkey', true ) );
     726    }
    710727}
Note: See TracChangeset for help on using the changeset viewer.