[wp-trac] [WordPress Trac] #53479: Unable to add widgets after Opting out of the Widgets Block Editor in WordPress 5.8-Beta2

WordPress Trac noreply at wordpress.org
Wed Jun 23 12:36:37 UTC 2021


#53479: Unable to add widgets after Opting out of the Widgets Block Editor in
WordPress 5.8-Beta2
-------------------------------------------------+-------------------------
 Reporter:  jamesros161                          |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  5.8
Component:  Customize                            |     Version:  trunk
 Severity:  blocker                              |  Resolution:
 Keywords:  needs-patch has-screenshots needs-   |     Focuses:
  testing                                        |
-------------------------------------------------+-------------------------

Comment (by zieladam):

 The culprit is the `return` line in `wp-includes/class-wp-customize-
 widgets.php`:

 {{{#!php
         public function sanitize_widget_instance( $value, $id_base = null
 ) {
                 global $wp_widget_factory;

                 if ( array() === $value ) {
                         return;
                 }

 }}}



 In 5.7, this said `return $value;`, so empty array in = empty array out.
 This played well with the following logic in `wp-includes/class-wp-
 customize-manager.php`:

 {{{#!php
         $value = $setting->sanitize( $unsanitized_value );
         if ( is_null( $value ) ) {
                 $validity = false;
         }
 }}}


 But now `sanitize` returns a `null` value instead of an empty array, hence
 the `$validity` becomes `false`. The change was introduced in the
 following commit by @noisysocks:

 https://github.com/WordPress/wordpress-
 develop/commit/00bc227eb8e7b09e9eb6390a74a23a3f3fcc2383

 @noisysocks, would you elaborate on the `return;` part? Will anything
 break if we return `$value` instead of null? If the answer is yes, we
 could condition the behavior on the widget editor used (as awful as it
 sounds :p).

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


More information about the wp-trac mailing list