WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#6636 closed defect (bug) (fixed)

Multi-widget data loss

Reported by: mdawaffe Owned by: mdawaffe
Milestone: 2.5.1 Priority: normal
Severity: major Version: 2.5
Component: General Keywords: has-patch needs-testing
Focuses: Cc:

Description

  1. Add a text widget to your sidebar. Give it a title and some text.
  2. Click "Save Changes".
  3. After the page reload, click "Edit" on that text widget.
  4. Click "Cancel" on that text widget.
  5. Click "Save Changes".
  6. Your text widget has just been emptied of all data.

The same thing happens with our other multi-widgets.

#6291 [7411] caused this regression.

The way widget canceling works, is that the JS disables all the form fields. The widget control callback sees that there is no $_POST data for that widget and skips it. The above change, however, guarantees that there will always be $_POST data for each widget and so "canceled" widgets are not skipped, and so "canceled" widgets are filled with empty data.

The means by which we detect widget canceling is not great; it can be much improved.

The attached, though, corrects the problem with the least code change: before updating the widget, the control function makes a more explicit check to make sure there is the $_POST data for that widget. If not, it will be skipped unless it is a brand new widget (user adds *new* text widget, user clicks "Edit", user clicks "Cancel" user clicks "Save Changes), in which case an empty widget is added.

Attachments (1)

6636.diff (3.7 KB) - added by mdawaffe 6 years ago.

Download all attachments as: .zip

Change History (4)

mdawaffe6 years ago

comment:1 mdawaffe6 years ago

  • Keywords has-patch needs-testing added
  • Owner changed from anonymous to mdawaffe
  • Status changed from new to assigned

comment:2 ryan6 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [7620]) Avoid data-loss when editing multi-widgets. Props mdawaffe. fixes #6636 for trunk

comment:3 ryan6 years ago

(In [7621]) Avoid data-loss when editing multi-widgets. Props mdawaffe. fixes #6636 for 2.5

Note: See TracTickets for help on using tickets.