#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
- Add a text widget to your sidebar. Give it a title and some text.
- Click "Save Changes".
- After the page reload, click "Edit" on that text widget.
- Click "Cancel" on that text widget.
- Click "Save Changes".
- 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.
(In [7620]) Avoid data-loss when editing multi-widgets. Props mdawaffe. fixes #6636 for trunk