Changeset 26028
- Timestamp:
- 11/06/2013 11:40:46 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/wp-includes/taxonomy.php (modified) (1 diff)
-
tests/phpunit/tests/term.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r26010 r26028 1711 1711 function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) { 1712 1712 $int_fields = array( 'parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id' ); 1713 if ( in_array( $field, $int_fields ) ) 1714 $value = absint( $value ); 1713 if ( in_array( $field, $int_fields ) ) { 1714 $value = (int) $value; 1715 if ( $value < 0 ) 1716 $value = 0; 1717 } 1715 1718 1716 1719 if ( 'raw' == $context ) -
trunk/tests/phpunit/tests/term.php
r26010 r26028 434 434 } 435 435 436 /** 437 * @ticket 17646 438 */ 436 439 function test_get_object_terms_types() { 437 440 $post_id = $this->factory->post->create(); … … 446 449 $term = array_shift( wp_get_object_terms( $post_id, $this->taxonomy, array( 'fields' => 'ids' ) ) ); 447 450 $this->assertInternalType( 'int', $term, 'term' ); 451 } 452 453 /** 454 * @ticket 25852 455 */ 456 function test_sanitize_term_field() { 457 $term = wp_insert_term( 'foo', $this->taxonomy ); 458 459 $this->assertEquals( 0, sanitize_term_field( 'parent', 0, $term['term_id'], $this->taxonomy, 'raw' ) ); 460 $this->assertEquals( 1, sanitize_term_field( 'parent', 1, $term['term_id'], $this->taxonomy, 'raw' ) ); 461 $this->assertEquals( 0, sanitize_term_field( 'parent', -1, $term['term_id'], $this->taxonomy, 'raw' ) ); 462 $this->assertEquals( 0, sanitize_term_field( 'parent', '', $term['term_id'], $this->taxonomy, 'raw' ) ); 448 463 } 449 464
Note: See TracChangeset
for help on using the changeset viewer.