#6605 closed defect (bug) (fixed)
WordPress-related widget upgrade issue
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 2.5.1 | Priority: | normal |
| Severity: | major | Version: | 2.5 |
| Component: | General | Keywords: | has-patch |
| Focuses: | Cc: |
Description
while debugging upgrade scripts from WP 2.1.3 to WP 2.5, I ran into a particularly nasty bug whereby sidebars get essentially flushed from their contents upon upgrading. Basically, the bug applies to the legacy category widget and to other widgets that, like it, went from single widget status to multi-widget status at some point.
changing wp_get_sidebars_widgets() fixes the issue:
switch ( $sidebars_widgets['array_version'] ) {
case 1 :
foreach ( $sidebars_widgets as $index => $sidebar )
if ( is_array($sidebar) )
foreach ( $sidebar as $i => $name ) {
$id = strtolower($name);
if ( isset($wp_registered_widgets[$id]) ) {
$_sidebars_widgets[$index][$i] = $id;
continue;
}
$id = sanitize_title($name);
if ( isset($wp_registered_widgets[$id]) ) {
$_sidebars_widgets[$index][$i] = $id;
continue;
}
$found = false;
foreach ( $wp_registered_widgets as $widget_id => $widget )
{
if ( strtolower($widget['name']) == strtolower($name) )
{
$_sidebars_widgets[$index][$i] = $widget['id'];
$found = true;
break;
}
elseif ( sanitize_title($widget['name']) == sanitize_title($name) )
{
$_sidebars_widgets[$index][$i] = $widget['id'];
$found = true;
break;
}
}
if ( $found )
{
continue;
}
unset($_sidebars_widgets[$index][$i]);
}
$_sidebars_widgets['array_version'] = 2;
$sidebars_widgets = $_sidebars_widgets;
unset($_sidebars_widgets);
basically, if it fails to spot the id, it does a "last chance" try by scanning the entire wp_registerd_widgets array in order to match the legacy ID against the new name.
D.
Attachments (1)
Change History (8)
Note: See
TracTickets for help on using
tickets.
not sure the diff will work, I did it using my own svn server