[wp-trac] [WordPress Trac] #53766: Legacy Widget block triggers update() method multiple times for one update

WordPress Trac noreply at wordpress.org
Fri Jul 23 19:14:40 UTC 2021


#53766: Legacy Widget block triggers update() method multiple times for one update
--------------------------+-----------------------------
 Reporter:  GDragoN       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Widgets       |    Version:
 Severity:  critical      |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I can't catch how it does it exactly, but, when the widget is saved, the
 update() method is called more than once in a chain.

 I have placed debug code (to log in to log file) in my widget at the end
 of the update() method, and I add a new element into the $instance array,
 and if that element is not set, I set it to 1, if it is, I increment it.
 After one save, I would expect that that value is set to 1, but it is set
 to 2 after every save. After every save, it is clear that the update() is
 called twice. The problem is that result from the first save, is used as
 an input for the new save. And, if some of the values of the $instance
 change type during save, that causes a major issue for the processing.


 Why the Legacy Widget runs update() twice in a chain (using the previous
 result as input for the next call), that needs to be fixed.

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


More information about the wp-trac mailing list