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 | Owned by: | 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
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
@
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.
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.