[wp-trac] [WordPress Trac] #48528: warning in wp-includes/class.wp-scripts.php:454: Cannot assign an empty string to a string offset

WordPress Trac noreply at wordpress.org
Thu Nov 7 12:55:58 UTC 2019


#48528: warning in wp-includes/class.wp-scripts.php:454: Cannot assign an empty
string to a string offset
---------------------------+-----------------------------
 Reporter:  dpacks         |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Script Loader  |    Version:  5.2.4
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 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
 <?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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48528>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list