Make WordPress Core


Ignore:
Timestamp:
09/10/2026 10:48:20 AM (31 hours ago)
Author:
jonsurrell
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-scripts.php

    r63440 r63579  
    528528                }
    529529
    530                 $script   = (array) $this->get_data( $handle, $position );
     530                $script   = $this->get_data( $handle, $position );
     531                $script   = false === $script ? array() : (array) $script;
    531532                $script[] = $data;
    532533
Note: See TracChangeset for help on using the changeset viewer.