WordPress.org

Make WordPress Core

Opened 2 weeks ago

Closed 2 weeks ago

#53313 closed defect (bug) (fixed)

Widgets REST API: Deleted widgets re-appear after accessing old widgets screen

Reported by: noisysocks Owned by: noisysocks
Milestone: 5.8 Priority: normal
Severity: normal Version: trunk
Component: REST API Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

From https://github.com/WordPress/gutenberg/issues/31575.

## Description

The REST API endpoint for deleting widgets does not seem to properly delete widgets.

## Step-by-step reproduction instructions

For making REST API requests, I use https://httpie.io and have the Basic Auth WordPress plugin installed, but use whatever suits you.

  1. Install the Classic Widgets plugin.
  2. Navigate to wp-admin/widgets.php.
  3. Add a widget.
  4. Find the widget's ID by hitting GET /wp-json/wp/v2/widgets.
  5. Delete the widget by hitting DELETE /wp-json/wp/v2/widgets/{id}?force=1.
  6. Hit GET /wp-json/wp/v2/widgets. Notice the widget is gone.
  7. Navigate again to wp-admin/widgets.php. Notice the widget appears in Inactive widgets.
  8. Hit GET /wp-json/wp/v2/widgets. Notice the widget appears again.

## Expected behaviour

The widget should not appear in steps 6 and 7.

## Actual behaviour

The widget re-appears.

Change History (2)

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


2 weeks ago

  • Keywords has-patch has-unit-tests added

The DELETE /wp/v2/widgets/:id?force=1 endpoint was only removing widgets from the 'sidebars_widgets' option and not actually deleting the widget's options from the "widget-$id_base" option. This PR implements widget deletion.

https://core.trac.wordpress.org/ticket/53313

#2 @noisysocks
2 weeks ago

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

In 51059:

REST API: Fix delete widget endpoint

Makes the DELETE /wp/v2/widgets/:id?force=1 endpoint actually delete the
widget from the "widget-$id_base" option and not just remove it from
'sidebars_widgets'.

Fixes #53313.
Props TimothyBlynJacobs.

Note: See TracTickets for help on using tickets.