WordPress.org

Make WordPress Core

Opened 5 hours ago

#48528 new defect (bug)

warning in wp-includes/class.wp-scripts.php:454: Cannot assign an empty string to a string offset

Reported by: dpacks Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.2.4
Component: Script Loader Keywords:
Focuses: Cc:
PR Number:

Description

When sending an empty value to wp_localize_script() a warning is issued stating:
Cannot assign an empty string to a string offset

How to reproduce:
call wp_localize_script() like this:

<?php
wp_localize_script('my_valid_handle', 'my_variable_name', '');

Analysis:
Sending an empty value for a variable is perfectly legit so there is no problem with the input.
The problem lies here: The code at line 449 treats $l10n forcefully as an array but the code at 454 wrongfully assumes $l10n is an array without checking.

Change History (0)

Note: See TracTickets for help on using tickets.