mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
A negative term parent value should be sanitized to 0, not 1. Fix a regression in sanitize_term_field() caused by [26010].
props mattheu for initial patch. fixes #25852. git-svn-id: https://develop.svn.wordpress.org/trunk@26028 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -433,6 +433,9 @@ class Tests_Term extends WP_UnitTestCase {
|
||||
unset( $GLOBALS['wp_taxonomies'][ $random_tax ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 17646
|
||||
*/
|
||||
function test_get_object_terms_types() {
|
||||
$post_id = $this->factory->post->create();
|
||||
$term = wp_insert_term( 'one', $this->taxonomy );
|
||||
@@ -447,6 +450,18 @@ class Tests_Term extends WP_UnitTestCase {
|
||||
$this->assertInternalType( 'int', $term, 'term' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 25852
|
||||
*/
|
||||
function test_sanitize_term_field() {
|
||||
$term = wp_insert_term( 'foo', $this->taxonomy );
|
||||
|
||||
$this->assertEquals( 0, sanitize_term_field( 'parent', 0, $term['term_id'], $this->taxonomy, 'raw' ) );
|
||||
$this->assertEquals( 1, sanitize_term_field( 'parent', 1, $term['term_id'], $this->taxonomy, 'raw' ) );
|
||||
$this->assertEquals( 0, sanitize_term_field( 'parent', -1, $term['term_id'], $this->taxonomy, 'raw' ) );
|
||||
$this->assertEquals( 0, sanitize_term_field( 'parent', '', $term['term_id'], $this->taxonomy, 'raw' ) );
|
||||
}
|
||||
|
||||
private function assertPostHasTerms( $post_id, $expected_term_ids, $taxonomy ) {
|
||||
$assigned_term_ids = wp_get_object_terms( $post_id, $taxonomy, array(
|
||||
'fields' => 'ids'
|
||||
|
||||
Reference in New Issue
Block a user