WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#19091 closed defect (bug) (fixed)

After theme switch inactive box is filled with widgets which I haven't used

Reported by: ocean90 Owned by: azaozz
Milestone: 3.3 Priority: normal
Severity: normal Version: 3.3
Component: Widgets Keywords:
Focuses: Cc:

Description

Clean install with this themes: Twenty Eleven (default), Twenty Ten and Toolbox.

After a theme switch to Twenty Ten or Toolbox the inactive widget box is filled with widgets which I haven't used, widgets which don't have custom settings. These are the widgets: http://cl.ly/BPAM

The box should be empty.

Attachments (1)

19091.patch (545 bytes) - added by SergeyBiryukov 2 years ago.

Download all attachments as: .zip

Change History (16)

comment:1 GaryJ2 years ago

I've seen this happen with at least one other theme too, so it appears to be something in core, rather than something within the Twenty* section.

Last edited 2 years ago by GaryJ (previous) (diff)

comment:2 nacin2 years ago

Is this reproducible on 3.2? If not, please move to the 3.3 milestone.

comment:3 ocean902 years ago

  • Cc SergeyBiryukov added

On 3.2 there were more widgets in this box, because of a bug in default widgets, see r18643.

Maybe Sergey can help.

comment:4 ocean902 years ago

I noticed, that the inactive widgets are the 7 widgets which aren't used.

The problem is in /wp-includes/widgets.php#L1224.

In my case $number is always 2.

Some var_dumps from retrieve_widgets after a Twenty Eleven to Twenty Ten switch:

var_dump( $registered_sidebar_keys ):

array(6) {
  [0]=>
  string(19) "primary-widget-area"
  [1]=>
  string(21) "secondary-widget-area"
  [2]=>
  string(24) "first-footer-widget-area"
  [3]=>
  string(25) "second-footer-widget-area"
  [4]=>
  string(24) "third-footer-widget-area"
  [5]=>
  string(25) "fourth-footer-widget-area"
}

var_dump( $sidebars_widgets ):

array(6) {
  ["wp_inactive_widgets"]=>
  array(0) {
  }
  ["sidebar-1"]=>
  array(6) {
    [0]=>
    string(8) "search-2"
    [1]=>
    string(14) "recent-posts-2"
    [2]=>
    string(17) "recent-comments-2"
    [3]=>
    string(10) "archives-2"
    [4]=>
    string(12) "categories-2"
    [5]=>
    string(6) "meta-2"
  }
  ["sidebar-2"]=>
  array(0) {
  }
  ["sidebar-3"]=>
  array(0) {
  }
  ["sidebar-4"]=>
  array(0) {
  }
  ["sidebar-5"]=>
  array(0) {
  }
}

var_dump( $shown_widgets ):

array(6) {
  [0]=>
  string(8) "search-2"
  [1]=>
  string(14) "recent-posts-2"
  [2]=>
  string(17) "recent-comments-2"
  [3]=>
  string(10) "archives-2"
  [4]=>
  string(12) "categories-2"
  [5]=>
  string(6) "meta-2"
}

var_dump( $lost_widgets ):

array(7) {
  [0]=>
  string(7) "pages-2"
  [1]=>
  string(10) "calendar-2"
  [2]=>
  string(7) "links-2"
  [3]=>
  string(6) "text-2"
  [4]=>
  string(5) "rss-2"
  [5]=>
  string(11) "tag_cloud-2"
  [6]=>
  string(10) "nav_menu-2"
}

var_dump( $sidebars_widgets ):

array(7) {
  ["wp_inactive_widgets"]=>
  array(7) {
    [0]=>
    string(7) "pages-2"
    [1]=>
    string(10) "calendar-2"
    [2]=>
    string(7) "links-2"
    [3]=>
    string(6) "text-2"
    [4]=>
    string(5) "rss-2"
    [5]=>
    string(11) "tag_cloud-2"
    [6]=>
    string(10) "nav_menu-2"
  }
  ["primary-widget-area"]=>
  array(6) {
    [0]=>
    string(8) "search-2"
    [1]=>
    string(14) "recent-posts-2"
    [2]=>
    string(17) "recent-comments-2"
    [3]=>
    string(10) "archives-2"
    [4]=>
    string(12) "categories-2"
    [5]=>
    string(6) "meta-2"
  }
  ["secondary-widget-area"]=>
  array(0) {
  }
  ["first-footer-widget-area"]=>
  array(0) {
  }
  ["second-footer-widget-area"]=>
  array(0) {
  }
  ["third-footer-widget-area"]=>
  array(0) {
  }
  ["fourth-footer-widget-area"]=>
  NULL
}

At the moment I'm not sure why $number must be >2.

comment:5 ocean902 years ago

  • Cc azaozz added

Related: r11427

SergeyBiryukov2 years ago

comment:6 follow-up: SergeyBiryukov2 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Awaiting Review to 3.3

Doesn't happen if I manually remove them from "Inactive Widgets" area and try again.

Widget options in this case are a bit different from the ones on a clean install:

(87, 0, 'widget_text', 'a:1:{s:12:"_multiwidget";i:1;}', 'yes'),
(88, 0, 'widget_rss', 'a:1:{s:12:"_multiwidget";i:1;}', 'yes'),
(106, 0, 'widget_pages', 'a:1:{s:12:"_multiwidget";i:1;}', 'yes'),
(107, 0, 'widget_calendar', 'a:1:{s:12:"_multiwidget";i:1;}', 'yes'),
(108, 0, 'widget_links', 'a:1:{s:12:"_multiwidget";i:1;}', 'yes'),
(109, 0, 'widget_tag_cloud', 'a:1:{s:12:"_multiwidget";i:1;}', 'yes'),
(110, 0, 'widget_nav_menu', 'a:1:{s:12:"_multiwidget";i:1;}', 'yes'),

On a clean install:

(87, 0, 'widget_text', 'a:2:{i:2;a:0:{}s:12:"_multiwidget";i:1;}', 'yes'),
(88, 0, 'widget_rss', 'a:2:{i:2;a:0:{}s:12:"_multiwidget";i:1;}', 'yes'),
(110, 0, 'widget_pages', 'a:2:{i:2;a:0:{}s:12:"_multiwidget";i:1;}', 'yes'),
(111, 0, 'widget_calendar', 'a:2:{i:2;a:0:{}s:12:"_multiwidget";i:1;}', 'yes'),
(112, 0, 'widget_links', 'a:2:{i:2;a:0:{}s:12:"_multiwidget";i:1;}', 'yes'),
(113, 0, 'widget_tag_cloud', 'a:2:{i:2;a:0:{}s:12:"_multiwidget";i:1;}', 'yes'),
(114, 0, 'widget_nav_menu', 'a:2:{i:2;a:0:{}s:12:"_multiwidget";i:1;}', 'yes'),

My guess is that wp_convert_widget_settings() shouldn't run for all newly registered widgets (including core widgets), which happens now. This leads (as I see it) to single instances being treated as copies. Adding a patch.

Related: [10784]

comment:7 in reply to: ↑ 6 azaozz2 years ago

  • Keywords has-patch removed
  • Milestone changed from 3.3 to Future Release

Replying to SergeyBiryukov:

19091.patch would disable converting a widget's settings from single to multi format. Not sure if that code is still needed, it was supposed to transparently convert these settings years ago. Perhaps the right fix is to make wp_convert_widget_settings() run on update from WP versions prior to 2.8. or even remove it completely and delete the old format settings.

comment:8 lancewillett2 years ago

  • Cc lancewillett added

comment:9 ryan2 years ago

  • Milestone changed from Future Release to 3.3

comment:10 ocean902 years ago

Jane: test site had 2010 as theme, with some widgets. activated 2011 on themes.php. Refreshed itself to themes.php?activated=true and showed alert message " New theme activated. This theme supports widgets, please visit the widgets settings screen to configure them." Go to widgets screen, widgets in primary sidebar in 2010 are not in sidebar, no widgets live anymore

Jane: switch back to 2010, same message appears on themes.php?activated=true and 2010 sidebar comes back


comment:11 ocean902 years ago

Related: #17979

How I could reproduce Jane's issue:

  • existing installation, custom Theme was active, I switched to 2010
  • I removed all (default) widgets.
  • Each sidebar gets a text widget
  • Go to themes.php change theme to 2011 and go to widget screen
  • Sidebars are empty
  • Widgets are saved in inactive sidebar

http://cl.ly/Btrs -> http://cl.ly/BuCf -> http://cl.ly/Bu41

Last edited 2 years ago by ocean90 (previous) (diff)

comment:12 follow-up: ocean902 years ago

lancewillett noticed that jane's issue and my reported issue could be unrelated. Maybe create a new ticket for jane's issue.

comment:13 azaozz2 years ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In [19333]:

Don't try to convert empty widget settings from old format, props SergeyBiryukov, fixes #19091

comment:14 lancewillett2 years ago

Looks good.

Confirmed in testing that new widgets are not added to Inactive when switching themes. Tested with themes that register their own widgets (which is where I saw this happening before).

comment:15 in reply to: ↑ 12 lancewillett2 years ago

Replying to ocean90:

lancewillett noticed that jane's issue and my reported issue could be unrelated. Maybe create a new ticket for jane's issue.

That is correct. It's an edge case. See #19291. It shouldn't be a blocker, but would be nice to fix it.

Note: See TracTickets for help on using tickets.