Don't double-unslash meta key when update_metadata() falls back on add_metadata().

Props jdgrimes.
Fixes #35795.

git-svn-id: https://develop.svn.wordpress.org/trunk@36509 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2016-02-11 17:34:59 +00:00
parent d2cbbfe28b
commit 71060260a1
2 changed files with 32 additions and 1 deletions
@@ -0,0 +1,30 @@
<?php
/**
* @group meta
* @covers ::update_metadata
*/
class Tests_Meta_UpdateMetadata extends WP_UnitTestCase {
/**
* @ticket 35795
*/
public function test_slashed_key_for_new_metadata() {
update_metadata( 'post', 123, wp_slash( 'foo\foo' ), 'bar' );
$found = get_metadata( 'post', 123, 'foo\foo', true );
$this->assertSame( 'bar', $found );
}
/**
* @ticket 35795
*/
public function test_slashed_key_for_existing_metadata() {
global $wpdb;
add_metadata( 'post', 123, wp_slash( 'foo\foo' ), 'bar' );
update_metadata( 'post', 123, wp_slash( 'foo\foo' ), 'baz' );
$found = get_metadata( 'post', 123, 'foo\foo', true );
$this->assertSame( 'baz', $found );
}
}