[wp-trac] [WordPress Trac] #52534: PHP 8: wp_localize_script() throws a warning if third parameter is a string.

WordPress Trac noreply at wordpress.org
Tue Feb 16 05:16:39 UTC 2021


#52534: PHP 8: wp_localize_script() throws a warning if third parameter is a
string.
-------------------------------------------+------------------------------
 Reporter:  peterwilsoncc                  |       Owner:  (none)
     Type:  defect (bug)                   |      Status:  new
 Priority:  normal                         |   Milestone:  Awaiting Review
Component:  Script Loader                  |     Version:
 Severity:  normal                         |  Resolution:
 Keywords:  php8 has-patch has-unit-tests  |     Focuses:
-------------------------------------------+------------------------------

Comment (by peterwilsoncc):

 In the [https://github.com/WordPress/wordpress-develop/pull/1007/files
 pull request]:

 * added some tests with strings and arrays
 * I would like to test some of the items that throw (passing `stdClass`)
 but not sure how best to test for exceptions
 * added an `is_string()` check before looping assuming the l10n data is an
 array
 * convert `$l10n` to an array rather than only doing so for the loop

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52534#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list