WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 22 months ago

#36772 closed defect (bug) (invalid)

Widget from deactivated plugin still has its position in a sidebar

Reported by: afercia Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Widgets Keywords: has-screenshots
Focuses: Cc:

Description

Really not an expert about widgets, and not sure if this is the expected behavior. Noticed while working on #23328.

This gets evident when setting the Widgets screen in "accessibility mode" from the Screen Options tab.

To reproduce:

  • enable a plugin that provides a widget
  • add the widget from the plugin to a sidebar
  • disable the plugin

At this point, my Sidebar has 3 widgets (without the one from the disabled plugin). But when editing one of the widgets in the sidebar, the select that shows the widgets "positions" shows 4 "positions". See screenshot below:

https://cldup.com/79lvX8oubq.png

Attachments (2)

36772.diff (2.2 KB) - added by welcher 2 years ago.
Initial Patch
empty_widget_area.png (45.8 KB) - added by welcher 22 months ago.

Download all attachments as: .zip

Change History (11)

#1 @welcher
2 years ago

  • Keywords has-patch dev-feedback added

sidebars_widgets stores an array of sidebar ID's which is another array with the widget instance id for each widget assigned to that sidebar id.

To my knowledge, there is no simple way to retrieve a list of registered id_base's so I've added a new array to the widget factory that tracks the id_base for each registered widget class. Using that and the sidebars_widgets filter, we are able to remove any instances of unregistered widgets.

@welcher
2 years ago

Initial Patch

#2 @welcher
2 years ago

  • Keywords needs-patch added; has-patch removed

Looks like unit tests are failing on my patch. Will address and update.

#4 @welcher
22 months ago

@afercia I reviewed this again with some fresh eyes and am starting to think that this actually desired behavior.

When I add a new widget in no-js mode to an empty Sidebar - there is a position available for selection. It looks to be adding what the new position of the widget being added would be. See attached screenshot.

#5 @afercia
22 months ago

@welcher I guess when adding a new widget, that's ok. The point is when editing existing widgets. If you follow the steps described above, there are 3 widgets and when editing one of them, I see 4 positions.

#6 @welcher
22 months ago

  • Keywords dev-feedback needs-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

@afercia can you try it again. I just ran the steps above and can't reproduce - it might be me though :)

#7 @welcher
22 months ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

#8 @afercia
22 months ago

@welcher right, can't reproduce on 4.9 or trunk. I still can reproduce on 4.8.3. I guess the changes to remap widgets made by @obenland introduced some clean-up related to "orphaned widgets". Do feel free to close :)

#9 @welcher
22 months ago

  • Resolution set to invalid
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.