[wp-trac] [WordPress Trac] #39693: Fix missing assignment of widgets on theme switch

WordPress Trac noreply at wordpress.org
Fri Sep 22 16:42:51 UTC 2017


#39693: Fix missing assignment of widgets on theme switch
--------------------------------------+------------------------
 Reporter:  melchoyce                 |       Owner:  obenland
     Type:  enhancement               |      Status:  reviewing
 Priority:  high                      |   Milestone:  4.9
Component:  Widgets                   |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+------------------------

Comment (by obenland):

 Replying to [comment:107 bpayton]:

 Love those questions! Researching the exact answers for those helped me
 too in exactly understanding how it works.

 > `// 6 default widgets + 1 orphaned calendar widget = 7.`
 > Where do the 6 default widgets come from in the following comment? Based
 on my reading of the test, there are 2 specified for
 `wp_inactive_widgets`. Where do the other 4 come from?

 When a site gets first installed,
 [https://core.trac.wordpress.org/browser/branches/4.8/src/wp-
 admin/includes/upgrade.php#L255 WP adds dummy info for these six widgets].
 When we run `wp_widgets_init()` at the top of each test,
 [https://core.trac.wordpress.org/browser/branches/4.8/src/wp-includes
 /class-wp-widget.php#L257 WP looks for existing settings and assigns IDs
 based on that], and starts with `1` if it can't find any.
 Finally, in `retreive_widgets()`,
 [https://core.trac.wordpress.org/browser/trunk/src/wp-
 includes/widgets.php?rev=41555#L1157 it compares the shown widgets with
 all registered widgets], and weeds out all widgets that are not those six
 default ones, or one that a user registered.

 > How do we know to look for `recent-comments-2` in the
 `wp_inactive_widgets` array?
 Recent Comments is one of the six default widgets, so it should always be
 there. BUT! That's not what the test should be testing for. It should make
 sure `'calendar-1'` is in the inactive sidebar, since we're testing to
 make sure orphaned widgets get folded into that!

 This is a left over from an earlier version of the test and I missed
 updating that together with the setup. Good catch!

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


More information about the wp-trac mailing list