Changeset 29865
- Timestamp:
- 10/09/2014 03:15:50 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r29863 r29865 1657 1657 * @param string $taxonomy The taxonomy name to use 1658 1658 * @param int $parent Optional. ID of parent term under which to confine the exists search. 1659 * @return mixed Returns 0 if the term does not exist. Returns the term ID if no taxonomy is specified 1660 * and the term ID exists. Returns an array of the term ID and the term taxonomy ID 1661 * if the taxonomy is specified and the pairing exists. 1659 * @return mixed Returns null if the term does not exist. Returns the term ID 1660 * if no taxonomy is specified and the term ID exists. Returns 1661 * an array of the term ID and the term taxonomy ID the taxonomy 1662 * is specified and the pairing exists. 1662 1663 */ 1663 1664 function term_exists( $term, $taxonomy = '', $parent = null ) { … … 1678 1679 1679 1680 $term = trim( wp_unslash( $term ) ); 1680 1681 if ( '' === $slug = sanitize_title($term) ) 1682 return 0; 1681 $slug = sanitize_title( $term ); 1683 1682 1684 1683 $where = 't.slug = %s'; -
trunk/tests/phpunit/tests/term.php
r29863 r29865 113 113 114 114 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' ) ); 116 129 } 117 130
Note: See TracChangeset
for help on using the changeset viewer.