Commit 0b6521fcb0 for wordpress.org
commit 0b6521fcb0afddbd025f218985d88c4578e9ddb6
Author: jonsurrell <jonsurrell@git.wordpress.org>
Date: Thu Sep 10 10:49:48 2026 +0000
Script Loader: Avoid a false entry in inline script data.
`WP_Scripts::get_data()` returns `false` when a handle has no `before` or `after` data, and casting that to an array produced `array( false )`. The first inline script added for a handle was therefore stored after an unused `false` entry. Missing inline script data is now treated as an empty array.
Developed in: https://github.com/WordPress/wordpress-develop/pull/12217
Follow-up to r36633.
Props vanyukov, sukhendu2002, jonsurrell, apermo.
Fixes #52320.
Built from https://develop.svn.wordpress.org/trunk@63579
git-svn-id: http://core.svn.wordpress.org/trunk@62755 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/class-wp-scripts.php b/wp-includes/class-wp-scripts.php
index f8d32d375d..36a0487bed 100644
--- a/wp-includes/class-wp-scripts.php
+++ b/wp-includes/class-wp-scripts.php
@@ -527,7 +527,8 @@ class WP_Scripts extends WP_Dependencies {
$position = 'before';
}
- $script = (array) $this->get_data( $handle, $position );
+ $script = $this->get_data( $handle, $position );
+ $script = false === $script ? array() : (array) $script;
$script[] = $data;
return $this->add_data( $handle, $position, $script );
diff --git a/wp-includes/version.php b/wp-includes/version.php
index ce5a4f8ec0..4987ff7a0e 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-alpha-63578';
+$wp_version = '7.2-alpha-63579';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.