WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#35963 new defect (bug)

Only remove item from WP_Dependencies::to_do if it was successfully processed

Reported by: pcfreak30 Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Script Loader Keywords: has-patch needs-unit-tests
Focuses: Cc:

Description

If WP_Dependencies::do_item returns false, the item is removed from being processed again. Due to this, if an item gets switched to the footer, it is never actually outputted. A common scenario is depending on jquery which depends on jquery-core and jquery-migrate. jquery is processed right, but jquery-core and jquery-migrate are moved to the bottom but still removed from the list.

The following example demonstrates:

<?php
add_action('wp_print_scripts', function () {
    if (!is_admin()) {
        $jquery = wp_scripts()->registered['jquery'];
        wp_dequeue_script('jquery');
        wp_deregister_script('jquery');
        wp_register_script('jquery', $jquery->src, $jquery->deps, $jquery->ver, true);
    }
}, 0);

Attached is a very simple patch to resolve this

Attachments (1)

35963_to_do_deps.patch (654 bytes) - added by pcfreak30 2 years ago.

Download all attachments as: .zip

Change History (4)

#1 @swissspidy
2 years ago

  • Keywords has-patch needs-unit-tests added

This ticket was mentioned in Slack in #core by obenland. View the logs.


2 years ago

#3 @ocean90
2 years ago

  • Milestone changed from Awaiting Review to Future Release
  • Version trunk deleted

Previously: #25247

Note: See TracTickets for help on using tickets.