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

Template Parts: Fix theme slug injection for patterns #5450

Closed
wants to merge 6 commits into from

Conversation

scruffian
Copy link

@scruffian scruffian commented Oct 10, 2023

Fixes: WordPress/gutenberg#55202
Trac ticket: https://core.trac.wordpress.org/ticket/59583

This ensures that the theme slug is correctly inserted into template parts that are inside patterns.

Furthermore, unit tests are added to prevent the same kind of regression in the future. The tests can be used to verify the fix: Cherry-pick 3cb17f8 and d077949 to trunk, run npm run test:php -- --group=blocks, and verify that it fails. Compare that to this branch where those tests pass (see CI, or test locally).

Props @gziolo for finding the problem


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.

@gziolo
Copy link
Member

gziolo commented Oct 10, 2023

3 unit tests failed with these changes so that needs to be fixed before we proceed:

Screenshot 2023-10-10 at 14 13 10

@ockham
Copy link
Contributor

ockham commented Oct 10, 2023

Good catch, thank you both!

I'll try to write a quick unit test to cover the theme attribute insertion in patterns so we're guarded against this kind of regression in the future. I'll push a commit to this PR if that's okay.

@ockham
Copy link
Contributor

ockham commented Oct 10, 2023

For book-keeping, we should probably file a Trac ticket for this (since it needs to go into 6.4 Beta 3, and we're fairly late in the cycle). Would either of you mind doing so? Probably enough to basically copy-paste WordPress/gutenberg#55202.

Otherwise I can take care of that once I have the unit test ready.

@ockham
Copy link
Contributor

ockham commented Oct 10, 2023

I'll try to write a quick unit test to cover the theme attribute insertion in patterns so we're guarded against this kind of regression in the future. I'll push a commit to this PR if that's okay.

3cb17f8

Verify that this covers the regression by cherry-picking the commit to trunk, and running npm run test:php -- --group=blocks there.

I'll add another test to cover theme injection in get_all_registered.

/**
* Should insert a theme attribute into Template Part blocks in registered patterns.
*
* @ticket XXXXX
Copy link
Contributor

Choose a reason for hiding this comment

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

TBD

@ockham
Copy link
Contributor

ockham commented Oct 10, 2023

I'll add another test to cover theme injection in get_all_registered.

d077949

Going to file the ticket so I can put the corred @ticket references in unit tests' PHPDoc.

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

The code changes look good. New unit tests were added to cover the regression discovered. Let's ensure that all unit tests pass on CI.

@ockham
Copy link
Contributor

ockham commented Oct 10, 2023

Looking good. Thanks all, I'll land it 😊

@ockham
Copy link
Contributor

ockham commented Oct 10, 2023

Committed to Core in https://core.trac.wordpress.org/changeset/56818.

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.

Template Parts not displaying when inside patterns
3 participants