#9703 closed defect (bug) (fixed)
widget save procedure is inconsistent with js on and off
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 2.8 | Priority: | highest omg bbq |
| Severity: | blocker | Version: | 2.8 |
| Component: | Widgets | Keywords: | has-patch tested commit |
| Focuses: | Cc: |
Description
I'm getting this awkward bug as I seek to debug a nav menu widget.
It's passing a variable length array to the update handler in order to fill it with items. The various field names are as follows:
name="' . $this->get_field_name('items') . '[type][]"
When saving using no js, everything works as expected. The js save procedure, however, is completely broken.
The $_POST sent to admin-ajax.php is the following:
array(11) {
["action"]=>
string(11) "save-widget"
["savewidgets"]=>
string(10) "5e80c3f1ef"
["sidebar"]=>
string(11) "top_sidebar"
["widget-nav_menu"]=>
array(1) {
[3]=>
array(3) {
["title"]=>
string(6) "Browse"
["dropdown"]=>
string(3) "url"
["items"]=>
array(3) {
["label"]=>
array(1) {
[0]=>
string(7) "Section"
}
["type"]=>
array(1) {
[0]=>
string(4) "page"
}
["ref"]=>
array(1) {
[0]=>
string(1) "8"
}
}
}
}
["widget-id"]=>
string(10) "nav_menu-3"
["id_base"]=>
string(8) "nav_menu"
["widget-width"]=>
string(3) "330"
["widget-height"]=>
string(3) "200"
["widget_number"]=>
string(1) "3"
["multi_number"]=>
string(0) ""
["add_new"]=>
string(0) ""
}
The data received without js, for the same data, is different:
array(11) {
["action"]=>
string(11) "save-widget"
["savewidgets"]=>
string(10) "5e80c3f1ef"
["sidebar"]=>
string(11) "top_sidebar"
["widget-nav_menu"]=>
array(1) {
[3]=>
array(3) {
["title"]=>
string(6) "Browse"
["dropdown"]=>
string(3) "url"
["items"]=>
array(3) {
["label"]=>
array(1) {
[0]=>
string(4) "Home",
[1]=>
string(7) "Section"
}
["type"]=>
array(1) {
[0]=>
string(4) "home",
[1]=>
string(4) "page"
}
["ref"]=>
array(1) {
[0]=>
string(4) "home",
[1]=>
string(1) "8"
}
}
}
}
["widget-id"]=>
string(10) "nav_menu-3"
["id_base"]=>
string(8) "nav_menu"
["widget-width"]=>
string(3) "330"
["widget-height"]=>
string(3) "200"
["widget_number"]=>
string(1) "3"
["multi_number"]=>
string(0) ""
["add_new"]=>
string(0) ""
}
Something clearly wrong is occurring over in widgets.js's save procedure, but my script-foo and jQuery-foo is a little too weak to fix it. Pointers (or a straight patch from Andrew) would be most welcome.
Attachments (1)
Change History (7)
#2
@
17 years ago
- Keywords has-patch tested commit added
attached patch fixes the issue in all instances where an empty [] might be found in an input's name.
there might be other areas in the code base where such a fix may be necessary.
#3
@
17 years ago
- Priority changed from normal to highest omg bbq
- Severity changed from major to blocker
please be so kind to get this into wp 2.8 asap. it's breaking a whole bunch of my plugins. :-|
further investigation leads me to the $.map() call in wpWidgets.save. It destroys the array, as revealed by:
$.map(data, function(n,i){ if ( n.name.match(/\[\]$/) ) alert(n.name); a[n.name] = n.value; });