• Resolved puggan

    (@puggan)


    In the wordpress source code there is 3 jquery scripts registered:
    wp-includes/script-loader.php:1124

    `
    // jQuery
    $scripts->add( ‘jquery’, false, array( ‘jquery-core’, ‘jquery-migrate’ ), ‘1.12.4-wp’ );
    $scripts->add( ‘jquery-core’, ‘/wp-includes/js/jquery/jquery.js’, array(), ‘1.12.4-wp’ );
    $scripts->add( ‘jquery-migrate’, “/wp-includes/js/jquery/jquery-migrate$suffix.js”, array(), ‘1.4.1’ );
    `

    jquery-core & jquery-migrate is real script,
    while jquery is just a meta-package that have the other 2 as dependencies.

    In the plugin version 3.4.1.2 and earlier, you unregister the meta-package, and then register the updated jquery as a replacement for the meta-package.

    You should instead replace the jquery-core.

    Current Bug:
    If someone list jquery-core as an dependency, they going to get both the old and the new version loaded.

    3.4.1.1 Bug:
    as you replaced jquery meta-package, someone listing jquery as dependecies didn’t get the jquery-migration.

    Goal:
    * if someone list jquery as dependency, both the new jquery and the new jquery-migrate should be loaded. (Status: works)
    * if someone list jquery-core as dependency, the new jquery should be loaded, but not the jquery-migrate. (Status: both new and the old jquery is loaded)
    * if someone list neither of the jquery packages, no jquery should be loaded. (Status: loads the new jquery and the new jquery-migrate.)

    — a/jquery-updater.php 2020-02-17 14:46:27.281044135 +0100
    +++ b/jquery-updater.php 2020-02-17 15:58:01.808581421 +0100
    @@ -19,26 +19,29 @@
    */
    function rw_jquery_updater()
    {

    – // jQuery
    – // Deregister core jQuery
    – wp_deregister_script(‘jquery’);
    – // Register
    – wp_enqueue_script(‘jquery’, plugins_url(‘/js/jquery-3.4.1.min.js’, __FILE__), false, ‘3.4.1’);
    + // jQuery Core
    + // Deregister jQuery core
    + wp_deregister_script(‘jquery-core’);
    + // Reregister jQuery core
    + wp_register_script(‘jquery-core’, plugins_url(‘/js/jquery-3.4.1.min.js’, __FILE__), [], ‘3.4.1’);

    // jQuery Migrate
    – // Deregister core jQuery Migrate
    + // Deregister jQuery Migrate
    wp_deregister_script(‘jquery-migrate’);
    – // Register
    – wp_enqueue_script(‘jquery-migrate’, plugins_url(‘/js/jquery-migrate-3.0.0.min.js’, __FILE__), array(
    – ‘jquery’
    – ), ‘3.0.0’); // require jquery, as loaded above
    + // Reregister jQuery Migrate
    + wp_register_script(‘jquery-migrate’, plugins_url(‘/js/jquery-migrate-3.0.0.min.js’, __FILE__), [‘jquery-core’], ‘3.0.0’);
    +
    + // jQuery
    + // Deregister jQuery (Meta)
    + wp_deregister_script(‘jquery’);
    + // Reregister jQuery (Meta)
    + wp_register_script(‘jquery’, false, [‘jquery-core’, ‘jquery-migrate’], ‘3.0.0’);
    }

    /**
    * Front-End
    */
    -add_action(‘wp_enqueue_scripts’, ‘rw_jquery_updater’);
    +add_action(‘wp_enqueue_scripts’, ‘rw_jquery_updater’, 1);
    add_action(‘login_enqueue_scripts’, ‘rw_jquery_updater’, 1); // since 3.4.0.1

    /**

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘3.4.1.1 rollback fix’ is closed to new replies.