Make WordPress Core

Ticket #31135: 31135.5.diff

File 31135.5.diff, 1.6 KB (added by MikeHansenMe, 10 years ago)

skip assigning length to variable since we only need it once

  • src/wp-includes/taxonomy.php

     
    341341        );
    342342        $args = wp_parse_args( $args, $defaults );
    343343
    344         if ( strlen( $taxonomy ) > 32 ) {
    345                 _doing_it_wrong( __FUNCTION__, __( 'Taxonomies cannot exceed 32 characters in length' ), '4.0' );
    346                 return new WP_Error( 'taxonomy_too_long', __( 'Taxonomies cannot exceed 32 characters in length' ) );
     344        if ( empty( $taxonomy ) || strlen( $taxonomy ) > 32 ) {
     345                _doing_it_wrong( __FUNCTION__, __( 'Taxonomies must be between 1 and 32 characters in length.' ), '4.2' );
     346                return new WP_Error( 'taxonomy_length_invalid', __( 'Taxonomies must be between 1 and 32 characters in length.' ) );
    347347        }
    348348
    349349        if ( false !== $args['query_var'] && ! empty( $wp ) ) {
    350                 if ( true === $args['query_var'] )
     350                if ( true === $args['query_var'] ) {
    351351                        $args['query_var'] = $taxonomy;
    352                 else
     352                } else {
    353353                        $args['query_var'] = sanitize_title_with_dashes( $args['query_var'] );
     354                }
    354355                $wp->add_query_var( $args['query_var'] );
    355356        }
    356357
  • tests/phpunit/tests/taxonomy.php

     
    154154        }
    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         *
    159168         * @expectedIncorrectUsage register_taxonomy