[wp-trac] [WordPress Trac] #31501: Customizer Save race condition when attempting to publish too soon after updating widget form fields with multiple edits

WordPress Trac noreply at wordpress.org
Mon Mar 16 08:48:32 UTC 2015


#31501: Customizer Save race condition when attempting to publish too soon after
updating widget form fields with multiple edits
--------------------------+-------------------------
 Reporter:  westonruter   |       Owner:  ocean90
     Type:  defect (bug)  |      Status:  reopened
 Priority:  normal        |   Milestone:  4.2
Component:  Customize     |     Version:  3.9
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  javascript
--------------------------+-------------------------
Changes (by westonruter):

 * status:  closed => reopened
 * resolution:  fixed =>


Comment:

 I found a defect that the patch for this ticket helped highlight, due to
 the new `jqxhr.abort()` call, but it would have happened before as well in
 case of a network error. The problem is when adding a new widget, the
 `processing` state will get incremented to prevent the Customizer from
 saving the settings before the server returns with the sanitized setting.
 If you immediately start making changes to the newly added widget, then
 this will cause the `jqshr.abort()` to fire which then results in the
 `jqxhr.fail()` callback to fire in the `updateWidget` method. The
 `updateWidget` method used when adding a new widget currently has a
 `complete` callback that throws any `jqxhr` error. If this happens, as in
 the case of abort, then the `processing` decrement in the `jqxhr.always()`
 callback will fail to run, and the `processing` state will get stuck at a
 non-zero number. The result is that the settings can then never be saved.

 The only reason why I added the `throw` of the error was to show something
 on the console.

 So I suggest removing it in [attachment:31501.2.diff] to prevent the
 `jqxhr.always()` callback from indeed not ''always'' getting called.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31501#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list