Make WordPress Core


Ignore:
Timestamp:
12/14/2018 03:16:56 AM (6 years ago)
Author:
desrosj
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, danielbachhuber.

Merges [43811] to trunk.

Fixes #43559.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tests/phpunit/tests/admin/includesPost.php

    r44122 r44153  
    800800        $this->assertSame( array( 'icon' => 'text' ), $blocks[ $name ] );
    801801    }
     802
     803    /**
     804     * @ticket 43559
     805     */
     806    public function test_post_add_meta_empty_is_allowed() {
     807        $p = self::factory()->post->create();
     808
     809        $_POST = array(
     810            'metakeyinput' => 'testkey',
     811            'metavalue'    => '',
     812        );
     813
     814        wp_set_current_user( self::$admin_id );
     815
     816        $this->assertNotFalse( add_meta( $p ) );
     817        $this->assertEquals( '', get_post_meta( $p, 'testkey', true ) );
     818    }
    802819}
Note: See TracChangeset for help on using the changeset viewer.