[wp-trac] [WordPress Trac] #56707: `register_block_type`'s `editor_script` handle fails if it is an array.

WordPress Trac noreply at wordpress.org
Sun Oct 16 06:18:41 UTC 2022


#56707: `register_block_type`'s `editor_script` handle fails if it is an array.
-------------------------------------------------+-------------------------
 Reporter:  nendeb55                             |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  6.1
Component:  Editor                               |     Version:  trunk
 Severity:  normal                               |  Resolution:
 Keywords:  needs-testing has-testing-info dev-  |     Focuses:
  feedback                                       |
-------------------------------------------------+-------------------------

Comment (by costdev):

 @nendeb55 Slight modification to minimize nesting:

 {{{#!php
 <?php
 public function __set( $name, $value ) {
         if ( ! in_array( $name, $this->deprecated_properties ) ) {
                 $this->{$name} = $value;
                 return;
         }

         $new_name = $name . '_handles';

         if ( is_array( $value ) ) {
                 $this->{$new_name} = $value;
                 return;
         }

         if ( ! is_string( $value ) ) {
                 return;
         }

         $this->{$new_name}[0] = $value;
 }
 }}}

 @zieladam, as Greg is on leave, you're up! 😆 (If someone else should be
 pinged, please do so!)

 Is there any chance that `$this->{$new_name}` will already have some
 entries that ''must'' stay there? In other words, is `$this->{$new_name} =
 $value` safe to use, or should we be **prepending** `$value` to
 `$this->{$new_name}` instead?

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


More information about the wp-trac mailing list