[wp-trac] [WordPress Trac] #53625: The 'explode' function does not work on widget block editor.

WordPress Trac noreply at wordpress.org
Fri Jul 16 13:21:43 UTC 2021


#53625: The 'explode' function does not work on widget block editor.
-----------------------------------------+-----------------------------
 Reporter:  subrataemfluence             |       Owner:  (none)
     Type:  defect (bug)                 |      Status:  closed
 Priority:  normal                       |   Milestone:
Component:  Widgets                      |     Version:  trunk
 Severity:  major                        |  Resolution:  invalid
 Keywords:  has-screenshots 2nd-opinion  |     Focuses:  administration
-----------------------------------------+-----------------------------
Changes (by zieladam):

 * status:  reopened => closed
 * resolution:   => invalid


Comment:

 @subrataemfluence The signature of `update` in WordPress core is as
 follows:

 {{{#!php
 function update( $new_instance, $old_instance );
 }}}

 However, in your sample, I see it's

 {{{#!php
 function update( $old_instance, $new_instance )
 }}}

 Notice how the arguments are reversed. So when you do `$instance['groups']
 = explode( ',', $new_instance['groups'] );` the second argument comes from
 the old widget instance and is already an array.

 When I switch the arguments order, it works like a charm.

 I did not get to the bottom of the discrepancy between the old editor and
 the new editor because that seems to be a problem only when the signature
 is wrong, but I'm happy to keep looking if something still isn't right. I
 am going to close this one again just to keep things tidy, but don't take
 it as me pushing for closure. Absolutely feel free to reopen if there are
 still some problems left to explore here.

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


More information about the wp-trac mailing list