Make WordPress Core

Ticket #40109: 40109.5.patch

File 40109.5.patch, 2.7 KB (added by johnbillion, 8 years ago)

Avoid counting some uncountable items

  • src/wp-includes/theme.php

    diff --git src/wp-includes/theme.php src/wp-includes/theme.php
    index 3c908f1820..b1d85e6f94 100644
    function wp_get_themes( $args = array() ) { 
    3535
    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.)
    4141                $current_theme = get_stylesheet();
    function get_theme_root_uri( $stylesheet_or_template = false, $theme_root = fals 
    627627function get_raw_theme_root( $stylesheet_or_template, $skip_cache = false ) {
    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;
    634635
  • tests/phpunit/tests/post/types.php

    diff --git tests/phpunit/tests/post/types.php tests/phpunit/tests/post/types.php
    index 31a51c2020..3c1210e088 100644
    class Tests_Post_Types extends WP_UnitTestCase { 
    423423                        'public' => true,
    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 );
    429430        }
    class Tests_Post_Types extends WP_UnitTestCase { 
    439440                        'register_meta_box_cb' => '__return_empty_string',
    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 );
    445447        }
  • tests/phpunit/tests/taxonomy.php

    diff --git tests/phpunit/tests/taxonomy.php tests/phpunit/tests/taxonomy.php
    index 252280eef4..b5fd536100 100644
    class Tests_Taxonomy extends WP_UnitTestCase { 
    764764
    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 );
    770771        }