Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#45890 closed defect (bug) (duplicate)

Customize: 2 browser tabs open in customizer can overwrite widgets of same type

Reported by: mauteri's profile mauteri Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.0.2
Component: Customize Keywords: needs-patch
Focuses: Cc:


Not seeing this exact bug in trac, so putting in a new ticket. I've found other issues related to how widgets are saved (mostly with them disappearing), but not this exactly when I did a search.

Steps to reproduce:

  1. Open 2 browser tabs and access customizer.
  2. Navigate to 2 different widget areas in each tab.
  3. Choose the same widget type (eg text widget) and populate with different content.
  4. Click publish in browser tab 1, then click publish in browser tab 2.

This will result in the instance of the widget of tab 2 being in both widget areas. If you update the widget after in either widget area, it will update as well in the other. If you look in the database in options table for sidebars_widgets you will see the same widget ID assigned to both widget areas.

This is caused by one widget overwriting the other widget as they are assigned the same ID on creation. They are then assigned to different widget areas.

Change History (1)

#1 @westonruter
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

You're right. This is an issue. It's previously been reported in #35669:

Concurrency: Since all widget instances of a given type are stored in a single option, if two users attempt to update two separate widgets at the same time, it is possible that one of the updates will get lost (see #31245). Additionally, the widgets admin page and widgets in the Customizer both get loaded with the max number (array index) for each widget type. When a new widget instance is created, this maximum number is incremented in memory and used in the new widget ID which is then passed to the server for saving. If two users have loaded the UI at the same time, when they both create a widget of a given type and save their widget changes, the one who saves last will overwrite the other user's widget since the two widgets would have the same ID. (See #32183 for more about the widget ID collisions, and see Customize Widgets Plus for a “Widget Number Incrementing” component which uses Ajax to generate new widget IDs in a more concurrency-safe manner.)

Note: See TracTickets for help on using tickets.