diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php index dced990fcd..3b425a6b8b 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php @@ -236,6 +236,18 @@ class WP_REST_Widgets_Controller extends WP_REST_Controller { public function update_item( $request ) { global $wp_widget_factory; + /* + * retrieve_widgets() contains logic to move "hidden" or "lost" widgets to the + * wp_inactive_widgets sidebar based on the contents of the $sidebars_widgets global. + * + * When batch requests are processed, this global is not properly updated by previous + * calls, resulting in widgets incorrectly being moved to the wp_inactive_widgets + * sidebar. + * + * See https://core.trac.wordpress.org/ticket/53657. + */ + wp_get_sidebars_widgets(); + retrieve_widgets(); $widget_id = $request['id']; @@ -300,6 +312,18 @@ class WP_REST_Widgets_Controller extends WP_REST_Controller { public function delete_item( $request ) { global $wp_widget_factory, $wp_registered_widget_updates; + /* + * retrieve_widgets() contains logic to move "hidden" or "lost" widgets to the + * wp_inactive_widgets sidebar based on the contents of the $sidebars_widgets global. + * + * When batch requests are processed, this global is not properly updated by previous + * calls, resulting in widgets incorrectly being moved to the wp_inactive_widgets + * sidebar. + * + * See https://core.trac.wordpress.org/ticket/53657. + */ + wp_get_sidebars_widgets(); + retrieve_widgets(); $widget_id = $request['id']; diff --git a/wp-includes/version.php b/wp-includes/version.php index 3a59606970..32bee113b3 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-51431'; +$wp_version = '5.9-alpha-51432'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.