Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#53557 closed defect (bug) (fixed)

REST API: Can't delete multiple widgets in a single batch request

Reported by: noisysocks's profile noisysocks Owned by: noisysocks's profile noisysocks
Milestone: 5.8 Priority: high
Severity: normal Version:
Component: REST API Keywords: has-patch has-unit-tests commit fixed-major dev-reviewed
Focuses: Cc:

Description

If you attempt to delete (with force=1) multiple widgets in a single batch request, only one widget is deleted.

Example request using https://httpie.io:

http -a admin:password POST http://wp-git-build.test/wp-json/batch/v1 requests:='[{"method":"DELETE","path":"/wp/v2/widgets/block-2?force=1"},{"method":"DELETE","path":"/wp/v2/widgets/block-3?force=1"},{"method":"DELETE","path":"/wp/v2/widgets/block-4?force=1"}]'

Change History (8)

This ticket was mentioned in PR #1452 on WordPress/wordpress-develop by noisysocks.


3 years ago
#1

  • Keywords has-patch has-unit-tests added

Trac ticket: https://core.trac.wordpress.org/ticket/53557

If you try to delete multiple widgets in a single batch request, only one widget is deleted. This is because deleting a widget sets the WP_Widget::$updated flag which blocks all future updates in a request. The fix is to reset the flag.

draganescu commented on PR #1452:


3 years ago
#2

@noisysocks this looks very good and fixes https://github.com/WordPress/gutenberg/issues/33069 Let's merge it!

draganescu commented on PR #1452:


3 years ago
#3

@noisysocks this looks very good and fixes https://github.com/WordPress/gutenberg/issues/33069 Let's merge it!

#4 @andraganescu
3 years ago

  • Keywords commit added

This was causing issues when deleting widgets. Orphaned widgets would randomly pop up in widget areas or in the inactive widgets area. Usually classic widgets remained. Applying the linked PR made the problem here impossible to repro. Let's add this patch.

#5 @SergeyBiryukov
3 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 51277:

REST API: Allow multiple widgets to be deleted in a single batch request.

This resets the WP_Widget::$updated flag when deleting a widget, to avoid blocking all future updates in a request.

Props noisysocks, andraganescu.
Fixes #53557.

#6 @SergeyBiryukov
3 years ago

  • Keywords fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for backporting to the 5.8 branch.

#7 @desrosj
3 years ago

  • Keywords dev-reviewed added

#8 @desrosj
3 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 51290:

REST API: Allow multiple widgets to be deleted in a single batch request.

This resets the WP_Widget::$updated flag when deleting a widget, to avoid blocking all future updates in a request.

Props noisysocks, andraganescu.
Merges [51277] to the 5.8 branch.
Fixes #53557.

Note: See TracTickets for help on using tickets.