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/src/wp-includes/taxonomy.php

    r29863 r29865  
    16571657 * @param string $taxonomy The taxonomy name to use
    16581658 * @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.
    16621663 */
    16631664function term_exists( $term, $taxonomy = '', $parent = null ) {
     
    16781679
    16791680    $term = trim( wp_unslash( $term ) );
    1680 
    1681     if ( '' === $slug = sanitize_title($term) )
    1682         return 0;
     1681    $slug = sanitize_title( $term );
    16831682
    16841683    $where = 't.slug = %s';
Note: See TracChangeset for help on using the changeset viewer.