Skip to content

Conversation

@hellofromtonya
Copy link
Contributor

@hellofromtonya hellofromtonya commented Jun 24, 2021

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

Uses the same strategy as the classic widgets screen by running retrieve_widgets(). In doing so, newly added sidebars are displayed in the Widgets Block Editor.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

* @ticket 41683
*/
public function test_get_items() {
wp_widgets_init();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this go in setUp() so that we can avoid some repetition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explored doing that. But it skews all the other tests that don't have it. In reviewing other widget tests, this init function is placed in each test that needs it. Not sure why yet. But it's on my test review TODO list across the test suite.

@TimothyBJacobs
Copy link
Member

We probably need to add retrieve_widgets to the other callbacks too, no?

@hellofromtonya
Copy link
Contributor Author

We probably need to add retrieve_widgets to the other callbacks too, no?

@TimothyBJacobs such as? I'm seeing the problem anywhere else. It's updating, removing, and rendering as expected. Do you foresee another problem area that could use it?

@TimothyBJacobs
Copy link
Member

I'm not sure to what degree Gutenberg is using those other callbacks and their responses. But if the data is missing for the get_items call, then won't it also be missing when getting a single sidebar?

@hellofromtonya
Copy link
Contributor Author

I'm not sure to what degree Gutenberg is using those other callbacks and their responses. But if the data is missing for the get_items call, then won't it also be missing when getting a single sidebar?

Hmm, that's a good point. I'm not seeing that effect. But let me do a little bit more testing to see what happens with get_item callback.

@hellofromtonya
Copy link
Contributor Author

I'm not sure to what degree Gutenberg is using those other callbacks and their responses. But if the data is missing for the get_items call, then won't it also be missing when getting a single sidebar?

@TimothyBJacobs In testing, seems get_item is currently not called in Widgets or Customizer or in the frontend.

What if it were called in the future or by another plugin/theme?
Added it and did more testing. Also ran the test suite which passed. I think you're right. Added it to get_item() in this PR to guard against future or yet to be reported issues. (See commit ebef519)

@TimothyBJacobs
Copy link
Member

Great, let's ship it!

@TimothyBJacobs
Copy link
Member

@hellofromtonya hellofromtonya deleted the fix/53489 branch January 7, 2022 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants