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.

git-svn-id: https://develop.svn.wordpress.org/trunk@44153 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers
2018-12-14 03:16:56 +00:00
parent e34fe23ff0
commit 88de9a1d7c
4 changed files with 89 additions and 4 deletions
@@ -799,4 +799,21 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
$this->assertArrayHasKey( $name, $blocks );
$this->assertSame( array( 'icon' => 'text' ), $blocks[ $name ] );
}
/**
* @ticket 43559
*/
public function test_post_add_meta_empty_is_allowed() {
$p = self::factory()->post->create();
$_POST = array(
'metakeyinput' => 'testkey',
'metavalue' => '',
);
wp_set_current_user( self::$admin_id );
$this->assertNotFalse( add_meta( $p ) );
$this->assertEquals( '', get_post_meta( $p, 'testkey', true ) );
}
}