Make WordPress Core


Ignore:
Timestamp:
10/09/2014 03:15:50 AM (10 years ago)
Author:
boonebgorges
Message:

Don't bail out of term_exists() when term sanitizes to an empty string.

This change brings return values for failures of this sort in line with other
failed lookups in term_exists(): a null value is now returned in all cases
where the queried term is not found.

Adds unit test for the sanitization issue. Modifies existing unit test to
reflect the change in return value for empty term strings.

Props boonebgorges, georgestephanis.
Fixes #29589.

File:
1 edited

Legend:

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

    r29863 r29865  
    113113
    114114    public function test_term_exists_term_trimmed_to_empty_string() {
    115         $this->assertSame( 0, term_exists( '   ' ) );
     115        $this->assertNull( term_exists( '   ' ) );
     116    }
     117
     118    /**
     119     * @ticket 29589
     120     */
     121    public function test_term_exists_existing_term_that_sanitizes_to_empty() {
     122        wp_insert_term( '//', 'category' );
     123        $this->assertNotEmpty( term_exists( '//' ) );
     124        $this->assertNotEmpty( term_exists( '//', 'category' ) );
     125
     126        wp_insert_term( '>>', 'category' );
     127        $this->assertNotEmpty( term_exists( '>>' ) );
     128        $this->assertNotEmpty( term_exists( '>>', 'category' ) );
    116129    }
    117130
Note: See TracChangeset for help on using the changeset viewer.