[wp-trac] [WordPress Trac] #51108: PHP 8: Incorrect wp_localize_script() usage in wp-admin/edit-form-blocks.php

WordPress Trac noreply at wordpress.org
Tue Feb 16 11:20:30 UTC 2021


#51108: PHP 8: Incorrect wp_localize_script() usage in wp-admin/edit-form-
blocks.php
----------------------------+-----------------------------
 Reporter:  SergeyBiryukov  |       Owner:  SergeyBiryukov
     Type:  defect (bug)    |      Status:  closed
 Priority:  normal          |   Milestone:  5.6
Component:  Editor          |     Version:
 Severity:  normal          |  Resolution:  fixed
 Keywords:  php8            |     Focuses:
----------------------------+-----------------------------

Comment (by SergeyBiryukov):

 Replying to [comment:2 azaozz]:
 > However, where is that warning coming from?

 For reference, the warning comes from the last line of that loop:
 {{{
 foreach ( (array) $l10n as $key => $value ) {
         if ( ! is_scalar( $value ) ) {
                 continue;
         }

         $l10n[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES,
 'UTF-8' );
 }
 }}}

 The `(array)` casting here only affects the `foreach` operator itself, but
 does not change the `$l10n` variable, which is still a string, so the
 `$l10n[ $key ] = ...` assignment produces a warning.

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


More information about the wp-trac mailing list