Make WordPress Core

Ticket #48154: 48514-warnings.diff

File 48514-warnings.diff, 1.5 KB (added by gziolo, 4 years ago)

Ensures that no warnings are displayed when no asset file found but JS file exists

  • src/wp-includes/script-loader.php

     
    288288        );
    289289
    290290        foreach ( $packages as $package ) {
    291                 $handle = 'wp-' . $package;
    292                 $path   = "/wp-includes/js/dist/$package$suffix.js";
     291                $handle       = 'wp-' . $package;
     292                $js_path      = "/wp-includes/js/dist/$package$suffix.js";
     293                $dependencies = array();
     294                $version      = false;
    293295
    294                 if ( ! file_exists( ABSPATH . $path ) ) {
    295                         continue;
     296                $asset_path =  ABSPATH . WPINC . "/assets/dist/$package$suffix.asset.php";
     297                if ( file_exists( $asset_path ) ) {
     298                        $asset_file   = include $asset_path;
     299                        $dependencies = $asset_file['dependencies'];
     300                        $version      = $asset_file['version'];
    296301                }
    297302
    298                 $asset_file   = include ABSPATH . WPINC . "/assets/dist/$package$suffix.asset.php";
    299                 $dependencies = $asset_file['dependencies'];
    300 
    301303                // Add dependencies that cannot be detected and generated by build tools.
    302304                switch ( $handle ) {
    303305                        case 'wp-block-library':
     
    307309                                array_push( $dependencies, 'media-models', 'media-views', 'postbox', 'wp-dom-ready' );
    308310                                break;
    309311                }
     312                $scripts->add( $handle, $js_path, $dependencies, $version, 1 );
    310313
    311                 $scripts->add( $handle, $path, $dependencies, $asset_file['version'], 1 );
    312 
    313314                if ( in_array( $package, $package_translations, true ) ) {
    314315                        $scripts->set_translations( $handle );
    315316                }