WordPress.org

Make WordPress Core

Ticket #43583: 43583-improvements2.patch

File 43583-improvements2.patch, 1.1 KB (added by ayeshrajans, 3 years ago)

Thanks for the suggestions. Appreciate if you could review the updated one. Please note that if xml or intl extensions are not loaded, this test will issue a warning. Ideally, this test should split for these edge cases and skip the test in PHPUnit if the classes are not available.

  • src/wp-includes/compat.php

    diff --git a/src/wp-includes/compat.php b/src/wp-includes/compat.php
    index cabe71d211..1c854a267d 100644
    a b function array_replace_recursive( $base = array(), $replacements = array() ) { 
    520520         * @return bool True if `$var` is countable, false otherwise.
    521521         */
    522522        function is_countable( $var ) {
    523                 return ( is_array( $var ) || $var instanceof Countable );
     523                return ( is_array( $var )
     524                                                 || $var instanceof Countable
     525                                                 || $var instanceof SimpleXMLElement
     526                                                 || $var instanceof ResourceBundle
     527                );
    524528        }
    525529}
    526530
  • tests/phpunit/tests/compat.php

    diff --git a/tests/phpunit/tests/compat.php b/tests/phpunit/tests/compat.php
    index 0f17b2d7a8..58dafd3ae7 100644
    a b public function countable_variable_test_data() { 
    228228                        array( array( 1, 2, 3 ), true ),
    229229                        array( (array) 1, true ),
    230230                        array( (object) array( 'foo', 'bar', 'baz' ), false ),
     231                        array( new SimpleXMLElement('<xml><tag>1</tag><tag>2</tag></xml>'), true),
     232                        array( new ResourceBundle('en', null), true),
    231233                );
    232234        }
    233235