WordPress.org

Make WordPress Core

Changeset 38174


Ignore:
Timestamp:
07/31/2016 06:24:21 PM (4 years ago)
Author:
ocean90
Message:

Script Loader: Ignore deregistered dependencies in wp_dependencies_unique_hosts().

Prevents a PHP warning when a handle of a deregistered dependency is still in the queue.

Fixes #37502.

Location:
trunk
Files:
2 edited

Legend:

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

    r38161 r38174  
    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 ];
  • trunk/tests/phpunit/tests/general/resourceHints.php

    r38122 r38174  
    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}
Note: See TracChangeset for help on using the changeset viewer.