• Hi – activating the latest version 6.9.3, produces 29 errors 404 in the console.
    Here is an example:
    GEThttps://localhost:8888/wp-includes/js/dist/vendor/lodash.min.js?ver=4.17.19
    When i deactivate the plugin no 404 errors appear.
    Do you have some information on this issue?
    regards – theo

Viewing 9 replies - 1 through 9 (of 9 total)
  • Problems are the prefetch link tags
    in my case they are ?pointing“ to to wrong location

    e.g.:

    
    <link href="/wp-includes/js/dist/vendor/lodash.min.js?ver=4.17.19" as="script" rel="prefetch">
    

    should be –>

    
    <link href="/wp/wp-includes/js/dist/vendor/lodash.min.js?ver=4.17.19" as="script" rel="prefetch">
    

    WP_SITEURL should be used (for these links) instead of WP_HOME

    hint:
    WP_SITEURL or site_url() (see: “WordPress-Address (URL)” in General > Settings)
    WP_HOME or home_url() (see: “Website-Address (URL)” in General > Settings)

    on some installations WP_SITEURL !== WP_HOME

    here is a quick fix (404 gone)
    WooCommerce (Version 6.9.3)

    file:
    […]/plugins/woocommerce/packages/woocommerce-blocks/src/AssetsController.php

    line 118
    change:
    'href' => $src,
    to:
    'href' => ( null === parse_url( $src )['host'] ? site_url() : '' ) . $src,

    full array_merge block

    
    $urls = array_merge(
      $urls,
      array_map(
        function( $src ) {
          return array(
            'href' => ( null === parse_url( $src )['host'] ? site_url() : '' ) . $src,
            'as'   => 'script',
          );
        },
        array_unique( array_filter( $resources ) )
      )
    );
    
    Thread Starter timholz

    (@timholz)

    @l3l3 – this is only half the rent, for this shows 29times:

    Notice: Undefined index: host in /Applications/MAMP/htdocs/wordpress/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/AssetsController.php on line 121

    I wonder if woocommerce authors are aware of this?

    • This reply was modified 2 years, 2 months ago by timholz.
    • This reply was modified 2 years, 2 months ago by timholz.

    @timholz
    okay you are using php7

    here:

    
    $urls = array_merge(
      $urls,
      array_map(
        function( $src ) {
          $url = parse_url( $src );
          $href = ( !array_key_exists( 'host', $url ) ? site_url() : '' ) . $src;
          return array(
            'href' => $href,
            'as'   => 'script',
          );
        },
        array_unique( array_filter( $resources ) )
      )
    );
    

    or shorter (one-line)

    
    $urls = array_merge(
      $urls,
      array_map(
        function( $src ) {
          return array(
            'href' => ( !array_key_exists( 'host', parse_url( $src ) ) ? site_url() : '' ) . $src,
            'as'   => 'script',
          );
        },
        array_unique( array_filter( $resources ) )
      )
    );
    
    Thread Starter timholz

    (@timholz)

    @l3l3 thanks – works!

    btw.: a fix is on the way (see github):
    https://github.com/woocommerce/woocommerce-blocks/pull/7211

    Thread Starter timholz

    (@timholz)

    @l3l3 thanks for the info. Have a nice evening.

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘29 scripts from wp-includes/dist cannot be found 404’ is closed to new replies.