From 6efef07ff82368cc1ec2d386625eb027ba97ea2e Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 23 Jun 2023 15:45:21 +0000 Subject: [PATCH] Script Loader: Replace `str_contains()` usage in `wp-includes/script-loader.php`. This avoids fatal errors on PHP < 8.0 if the file is included via `wp-admin/load-scripts.php` or `wp-admin/load-styles.php`, in which case the polyfills from `wp-includes/compat.php` are not loaded. Follow-up to [55703], [55710], [55988]. Props ryelle. See #58206. Built from https://develop.svn.wordpress.org/trunk@56002 git-svn-id: http://core.svn.wordpress.org/trunk@55514 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/script-loader.php | 14 ++++++++++++-- wp-includes/version.php | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index fa0c2856a1..0c8cd50e85 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -651,7 +651,12 @@ function wp_scripts_get_suffix( $type = '' ) { // Include an unmodified $wp_version. require ABSPATH . WPINC . '/version.php'; - $develop_src = str_contains( $wp_version, '-src' ); + /* + * Note: str_contains() is not used here, as this file can be included + * via wp-admin/load-scripts.php or wp-admin/load-styles.php, in which case + * the polyfills from wp-includes/compat.php are not loaded. + */ + $develop_src = false !== strpos( $wp_version, '-src' ); if ( ! defined( 'SCRIPT_DEBUG' ) ) { define( 'SCRIPT_DEBUG', $develop_src ); @@ -1480,7 +1485,12 @@ function wp_default_styles( $styles ) { require ABSPATH . WPINC . '/version.php'; if ( ! defined( 'SCRIPT_DEBUG' ) ) { - define( 'SCRIPT_DEBUG', str_contains( $wp_version, '-src' ) ); + /* + * Note: str_contains() is not used here, as this file can be included + * via wp-admin/load-scripts.php or wp-admin/load-styles.php, in which case + * the polyfills from wp-includes/compat.php are not loaded. + */ + define( 'SCRIPT_DEBUG', false !== strpos( $wp_version, '-src' ) ); } $guessurl = site_url(); diff --git a/wp-includes/version.php b/wp-includes/version.php index 0e3db3f6bf..0d805bb429 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-alpha-56001'; +$wp_version = '6.3-alpha-56002'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.