Make WordPress Core

Ticket #37502: 37502.patch

File 37502.patch, 1.4 KB (added by ocean90, 7 years ago)
  • src/wp-includes/general-template.php

     
    28742874        foreach ( array( $wp_scripts, $wp_styles ) as $dependencies ) {
    28752875                if ( $dependencies instanceof WP_Dependencies && ! empty( $dependencies->queue ) ) {
    28762876                        foreach ( $dependencies->queue as $handle ) {
     2877                                if ( ! isset( $dependencies->registered[ $handle ] ) ) {
     2878                                        continue;
     2879                                }
     2880
    28772881                                /* @var _WP_Dependency $dependency */
    28782882                                $dependency = $dependencies->registered[ $handle ];
    28792883                                $parsed     = wp_parse_url( $dependency->src );
  • tests/phpunit/tests/general/resourceHints.php

     
    163163                $this->assertEquals( $expected, $actual );
    164164                $this->assertNotContains( $unexpected, $actual );
    165165        }
     166
     167        /**
     168         * @ticket 37502
     169         */
     170        function test_deregistered_scripts_are_ignored() {
     171                $expected = "<link rel='dns-prefetch' href='//s.w.org'>\n";
     172
     173                wp_enqueue_script( 'test-script', 'http://example.org/script.js' );
     174                wp_deregister_script( 'test-script' );
     175
     176                $actual = get_echo( 'wp_resource_hints' );
     177                $this->assertEquals( $expected, $actual );
     178        }
    166179}