Make WordPress Core


Ignore:
Timestamp:
11/06/2013 11:40:46 PM (11 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term.php

    r26010 r26028  
    434434    }
    435435
     436    /**
     437     * @ticket 17646
     438     */
    436439    function test_get_object_terms_types() {
    437440        $post_id = $this->factory->post->create();
     
    446449        $term = array_shift( wp_get_object_terms( $post_id, $this->taxonomy, array( 'fields' => 'ids' ) ) );
    447450        $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' ) );
    448463    }
    449464
Note: See TracChangeset for help on using the changeset viewer.