Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport: Store legacy sidebars when switching to a block theme #3893

Closed

Conversation

Mamaduka
Copy link
Member

Trac ticket: https://core.trac.wordpress.org/ticket/57531
Related Gutenberg PR: WordPress/gutenberg#45509

Testing instructions without package updates

  1. Switch to the Twenty Twenty theme.
  2. Confirm sidebars have at least one widget by going to Appearance > Widgets
  3. Switch to any block theme. I was using Twenty Twenty-Three in my tests.
  4. Make a get request to the sidebars endpoint. It requires auth, but the Application Password could be used for basic auth.
  5. Confirm that the request loads the same sidebars registered for the Twenty Twenty theme.

Example request made by the editor.

GET /wp-json/wp/v2/sidebars?context=edit&_fields=id,name,description,status,widgets

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.

@Mamaduka
Copy link
Member Author

@hellofromtonya, I'm unsure what would be the right place to add PHPUnit tests for this change or the actual "unit" we want to test. In the plugin, the feature is covered by e2e tests.

Copy link
Contributor

@audrasjb audrasjb left a comment

Choose a reason for hiding this comment

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

@Mamaduka I aded a small comment, but otherwise the logic looks good to me 👍

src/wp-includes/widgets.php Outdated Show resolved Hide resolved
@Mamaduka
Copy link
Member Author

Thank you, @audrasjb!

Do you have any suggestions about the PHPUnit tests - #3893 (comment)?

@audrasjb
Copy link
Contributor

Concerning unit tests, maybe try to verify that classic sidebars are stored when switching to a block theme?

@Mamaduka
Copy link
Member Author

That makes sense, thank you.

I like the "classic sidebars" term and reference our other discussions from #3902 (comment). Do you think I should change legacy_sidebars to classic_sidebars?

@audrasjb
Copy link
Contributor

Yeah definitely! I think it would be easier to identify what is it: the system used before blocks started to handle WordPress content dataset :)

Yes it is legacy, but "legacy" can also be used for "legacy Classic" functions/classes/methods/concepts (= legacy-legacy stuff 🤪 ). Let's disambiguate when possible! :D

@Mamaduka
Copy link
Member Author

  • Fixed docblock.
  • Updated the theme mod name.
  • Added simple unit tests.

@hellofromtonya
Copy link
Contributor

I like the "classic sidebars" term and reference our other discussions from #3902 (comment). Do you think I should change legacy_sidebars to classic_sidebars?

I agree with @audrasjb that "classic" is preferred over "legacy" 👍

@Mamaduka I'll look at the PHPUnit. Thank you for adding it!

Test Reports: I asked @ironprogrammer to do his magic in testing this PR. If anyone has time, please test and add a test report too.

@hellofromtonya
Copy link
Contributor

@ironprogrammer tested the PR and submitted a Test Report https://core.trac.wordpress.org/ticket/57531#comment:13. Works 👍

@hellofromtonya
Copy link
Contributor

Currently reviewing for commit.

@hellofromtonya
Copy link
Contributor

@Mamaduka I switched the way this PR is tested by:

  • Adding a new test class for the new function _wp_block_theme_register_classic_sidebars().
  • Testing the "inactive" state in the REST API.

By doing so, it's now testing different paths for this specific change including:

  • Does the sidebar register on theme switch after invoking _wp_block_theme_register_classic_sidebars()?
  • Does the REST Controller set the sidebar to inactive?
  • Does the switch_theme() set the theme mod?

Copy link
Contributor

@hellofromtonya hellofromtonya left a comment

Choose a reason for hiding this comment

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

  • Confirmed this PR includes the changes from the GB PR ✅
  • It has a test report ✅
  • It has unit/integration tests ✅

It's ready for commit (assuming the CI jobs pass this time 🤣 ) 👍

@hellofromtonya
Copy link
Contributor

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.

4 participants