Widgets: Prevent widgets unintentionally being moved to the inactive sidebar.
This fixes a bug where widgets are unintentionally moved to the `wp_inactive_widgets` sidebar when batch updates occur through the REST API. When batch requests are processed, only `$_wp_sidebars_widgets is updated by previous calls to `WP_REST_Widgets_Controller::create_item()`. `$sidebars_widgets` is not aware of the new widget’s intended location, and `retrieve_widgets()` mistakenly flags the widget as inactive. Calling `wp_get_sidebars_widgets()` before `retrieve_widgets()` ensures both global variables match and is intended as a temporary fix until the root cause of the problem can be fixed. Props zieladam, htmgarcia, timothyblynjacobs. Fixes #53657. Built from https://develop.svn.wordpress.org/trunk@51432 git-svn-id: http://core.svn.wordpress.org/trunk@51043 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
440fd76242
commit
88309aa27e
|
@ -236,6 +236,18 @@ class WP_REST_Widgets_Controller extends WP_REST_Controller {
|
||||||
public function update_item( $request ) {
|
public function update_item( $request ) {
|
||||||
global $wp_widget_factory;
|
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();
|
retrieve_widgets();
|
||||||
|
|
||||||
$widget_id = $request['id'];
|
$widget_id = $request['id'];
|
||||||
|
@ -300,6 +312,18 @@ class WP_REST_Widgets_Controller extends WP_REST_Controller {
|
||||||
public function delete_item( $request ) {
|
public function delete_item( $request ) {
|
||||||
global $wp_widget_factory, $wp_registered_widget_updates;
|
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();
|
retrieve_widgets();
|
||||||
|
|
||||||
$widget_id = $request['id'];
|
$widget_id = $request['id'];
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue