WordPress.org

Make WordPress Core

Changeset 31449


Ignore:
Timestamp:
02/13/2015 04:26:37 PM (5 years ago)
Author:
johnbillion
Message:

Return a WP_Error if an empty name is provided when registering a taxonomy.

Fixes #31135
Props tyxla, MikeHansenMe

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy.php

    r31418 r31449  
    346346    $args = wp_parse_args( $args, $defaults );
    347347
    348     if ( strlen( $taxonomy ) > 32 ) {
    349         _doing_it_wrong( __FUNCTION__, __( 'Taxonomies cannot exceed 32 characters in length' ), '4.0' );
    350         return new WP_Error( 'taxonomy_too_long', __( 'Taxonomies cannot exceed 32 characters in length' ) );
     348    if ( empty( $taxonomy ) || strlen( $taxonomy ) > 32 ) {
     349        _doing_it_wrong( __FUNCTION__, __( 'Taxonomy names must be between 1 and 32 characters in length.' ), '4.2' );
     350        return new WP_Error( 'taxonomy_length_invalid', __( 'Taxonomy names must be between 1 and 32 characters in length.' ) );
    351351    }
    352352
  • trunk/tests/phpunit/tests/taxonomy.php

    r31307 r31449  
    155155
    156156    /**
     157     * @ticket 31135
     158     *
     159     * @expectedIncorrectUsage register_taxonomy
     160     */
     161    function test_register_short_taxonomy() {
     162        $this->assertInstanceOf( 'WP_Error', register_taxonomy( '', 'post', array() ) );
     163    }
     164
     165    /**
    157166     * @ticket 21593
    158167     *
Note: See TracChangeset for help on using the changeset viewer.