From 01a3632b15dab29d03816a967b5e3a6c7ef5ac68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20=28Greg=29=20Zi=C3=83=C2=B3=C3=85=E2=80=9Akowsk?= =?UTF-8?q?i?= Date: Tue, 7 Jan 2020 15:26:44 +0000 Subject: [PATCH] Build Tools: do not include assets for JS dependencies that do not exist. This is a follow-up for #48154, where we started including *.asset.php files to declare package dependencies. This works well but creates warnings in environments where the package does not exist because WordPress was not fully built. Props jeherve, swissspidy. Fixes #49144. git-svn-id: https://develop.svn.wordpress.org/trunk@47048 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/script-loader.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 0267f9cd11..9fa1ec0a23 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -285,9 +285,14 @@ function wp_default_packages_scripts( &$scripts ) { ); foreach ( $packages as $package ) { - $handle = 'wp-' . $package; - $path = "/wp-includes/js/dist/$package$suffix.js"; - $asset_file = include( ABSPATH . WPINC . "/assets/dist/$package$suffix.asset.php" ); + $handle = 'wp-' . $package; + $path = "/wp-includes/js/dist/$package$suffix.js"; + + if ( ! file_exists( ABSPATH . $path ) ) { + continue; + } + + $asset_file = include ABSPATH . WPINC . "/assets/dist/$package$suffix.asset.php"; $dependencies = $asset_file['dependencies']; // Add dependencies that cannot be detected and generated by build tools.