WordPress.org

Make WordPress Core

Changeset 41174


Ignore:
Timestamp:
07/27/2017 04:59:36 PM (4 years ago)
Author:
johnbillion
Message:

General: Avoid counting uncountable values when reading theme directories, and in some unit tests.

See #40109

Location:
trunk
Files:
3 edited

Legend:

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

    r41168 r41174  
    3636    $theme_directories = search_theme_directories();
    3737
    38     if ( count( $wp_theme_directories ) > 1 ) {
     38    if ( is_array( $wp_theme_directories ) && count( $wp_theme_directories ) > 1 ) {
    3939        // Make sure the current theme wins out, in case search_theme_directories() picks the wrong
    4040        // one in the case of a conflict. (Normally, last registered theme root wins.)
     
    628628    global $wp_theme_directories;
    629629
    630     if ( count($wp_theme_directories) <= 1 )
     630    if ( ! is_array( $wp_theme_directories ) || count( $wp_theme_directories ) <= 1 ) {
    631631        return '/themes';
     632    }
    632633
    633634    $theme_root = false;
  • trunk/tests/phpunit/tests/post/types.php

    r40635 r41174  
    424424        ) );
    425425
    426         $this->assertSame( 1, count( $wp_filter['future_foo'] ) );
     426        $this->assertArrayHasKey( 'future_foo', $wp_filter );
     427        $this->assertSame( 1, count( $wp_filter['future_foo']->callbacks ) );
    427428        $this->assertTrue( unregister_post_type( 'foo' ) );
    428429        $this->assertArrayNotHasKey( 'future_foo', $wp_filter );
     
    440441        ) );
    441442
    442         $this->assertSame( 1, count( $wp_filter['add_meta_boxes_foo'] ) );
     443        $this->assertArrayHasKey( 'add_meta_boxes_foo', $wp_filter );
     444        $this->assertSame( 1, count( $wp_filter['add_meta_boxes_foo']->callbacks ) );
    443445        $this->assertTrue( unregister_post_type( 'foo' ) );
    444446        $this->assertArrayNotHasKey( 'add_meta_boxes_foo', $wp_filter );
  • trunk/tests/phpunit/tests/taxonomy.php

    r40921 r41174  
    765765        register_taxonomy( 'foo', 'post' );
    766766
    767         $this->assertSame( 1, count( $wp_filter['wp_ajax_add-foo'] ) );
     767        $this->assertArrayHasKey( 'wp_ajax_add-foo', $wp_filter );
     768        $this->assertSame( 1, count( $wp_filter['wp_ajax_add-foo']->callbacks ) );
    768769        $this->assertTrue( unregister_taxonomy( 'foo' ) );
    769770        $this->assertArrayNotHasKey( 'wp_ajax_add-foo', $wp_filter );
Note: See TracChangeset for help on using the changeset viewer.