-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Fix duplicate template parts logic overriding existing template part #47128
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
Fix duplicate template parts logic overriding existing template part #47128
Conversation
|
Size Change: +3 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
noisysocks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense and works locally 👍
|
Flaky tests detected in c6cc8fe. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3908829172
|
c38b70a to
c6cc8fe
Compare
|
The Playwright Github Action was failing at the install step, so I've just given this a rebase to see if that gets them passing again. |
apeatling
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch @andrewserong! Works 👍
What?
Follow up to #47082
Ensure slugs created via the logic to avoid duplicate names for template parts are based on the unique title, and not the originally passed in title.
Why?
This is a subtle issue — it only appears when the duplicate template part is overriding a template part that is provided as part of the theme. If there is already an update to that template part, then an entry exists for it in the database, so the duplicate template part is created correctly. However, if the user has never altered the template part, then nothing exists in the database, so the generated slug might match the existing template part, causing the template part creation to override the existing template part.
How?
Swap the order so that
getCleanTemplatePartSlugcomes aftergetUniqueTemplatePartTitleand pass in theuniqueTitle.Testing Instructions
Following the same instructions as #47082, however first ensure that you're working from a clean slate and any adjustments to template parts in your theme have been cleared:
Screenshots or screencast