[wp-trac] [WordPress Trac] #32183: Widget ID auto-increments conflict for concurrent users

WordPress Trac noreply at wordpress.org
Wed Apr 29 09:20:47 UTC 2015

#32183: Widget ID auto-increments conflict for concurrent users
 Reporter:  westonruter   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  4.3
Component:  Widgets       |    Version:  2.8
 Severity:  normal        |   Keywords:  needs-patch
  Focuses:                |
 Each WP_Widget 2.0 “multi-widget” gets an index number associated with
 each instance of a give type. When you add a widget, this number gets
 incremented (`widget.set( 'multi_number', widget.get( 'multi_number' ) + 1
 );`). The initial multi-number is calculated from the
 `next_widget_id_number()` function which takes the max number currently
 used, and increments it by one. The same approach is used in the widgets
 admin page and the Widget Customizer.

 For frequently-used widgets, the above problem will happen frequently
 where two users will try to add the same widget at the same time, and thus
 they will start out with the same initial `multi_number`, resulting in the
 same widget ID. When they both save their changes, one user's widget will
 override the other user's widget: whoever saves last. Likewise, it is
 possible for multiple widgets to be deleted in one session (from the
 widgets admin page, since Customizer only removes widgets by moving them
 to the Inactive Widgets sidebar) then new ones added back in other
 sessions and the initial `multi_number` will not be consistent. In other
 words, the `multi_number` for each widget type needs to be synced across
 each Customizer session along with the actual setting values.

 For concurrent editing of widgets, see:

 #31436: Handle conflicts in concurrent Customizer sessions
 #12722: Concurrent editing of widgets (on admin page)

Ticket URL: <https://core.trac.wordpress.org/ticket/32183>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list