Skip to content

Template activation: skip gutenberg_get_registered_block_templates query when no slugs are left to find - #72795

Merged
ellatrix merged 2 commits into
trunkfrom
fix/template-activation-remaining-slugs
Oct 30, 2025
Merged

ellatrix merged 2 commits into
trunkfrom
fix/template-activation-remaining-slugs

Conversation

@ellatrix

Copy link
Copy Markdown
Member

What?

Closes #72786. Cc @bacoords.

When no slugs are left to find (because they were all found in the database), skip the registered templates query instead of calling it with slug__in set to an empty array. This could confuse plugins in thinking they need to return all registered templates.

Why?

Prevents the function that gets registered templates from returning all registered templates. If it returns templates that have slugs that were not requested, there will be PHP warnings.

How?

Check $remaining_slugs.

Testing Instructions

Install Woo. Create a front-page template in the site editor and set it active. The front page should have no PHP warnings.

Testing Instructions for Keyboard

Screenshots or screencast

Before After

@github-actions

github-actions Bot commented Oct 29, 2025 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: Aljullu <aljullu@git.wordpress.org>
Co-authored-by: kmanijak <karolmanijak@git.wordpress.org>
Co-authored-by: bacoords <bacoords@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ellatrix
ellatrix requested review from Aljullu and kmanijak October 29, 2025 16:49
@ellatrix ellatrix added [Type] Bug An existing feature does not function as intended Backport to WP 6.9 Beta/RC Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) labels Oct 29, 2025

@Aljullu Aljullu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, confirming the warnings from Gutenberg are gone.

I can still see the warnings from WordPress (I'm on 6.9 beta 2), though. Is that expected? I guess this PR needs to be backported?

Image

@kmanijak kmanijak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice one! Tested with WP 6.8 + GB and warnings are gone!

With WP 6.9 beta 2 + GB they're still there (half less) but I assume it's because how compat works and both versions of activation (from beta and compat) run, right?

@ellatrix

Copy link
Copy Markdown
Member Author

Yes, we will need to backport the PHP changes

@ellatrix
ellatrix force-pushed the fix/template-activation-remaining-slugs branch from 2902e42 to 772ba3b Compare October 30, 2025 12:16
@ellatrix

Copy link
Copy Markdown
Member Author

Thank you all!

@ellatrix
ellatrix merged commit 127cb5a into trunk Oct 30, 2025
34 checks passed
@ellatrix
ellatrix deleted the fix/template-activation-remaining-slugs branch October 30, 2025 12:55
@github-actions github-actions Bot added this to the Gutenberg 22.1 milestone Oct 30, 2025
gutenbergplugin pushed a commit that referenced this pull request Oct 30, 2025
…ery when no slugs are left to find (#72795)

Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: Aljullu <aljullu@git.wordpress.org>
Co-authored-by: kmanijak <karolmanijak@git.wordpress.org>
Co-authored-by: bacoords <bacoords@git.wordpress.org>
@github-actions github-actions Bot added the Backported to WP Core Pull request that has been successfully merged into WP Core label Oct 30, 2025
@github-actions

Copy link
Copy Markdown

I just cherry-picked this PR to the wp/6.9 branch to get it included in the next release: ad996fb

cbravobernal pushed a commit that referenced this pull request Nov 5, 2025
…ery when no slugs are left to find (#72795)

Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: Aljullu <aljullu@git.wordpress.org>
Co-authored-by: kmanijak <karolmanijak@git.wordpress.org>
Co-authored-by: bacoords <bacoords@git.wordpress.org>
@cbravobernal

Copy link
Copy Markdown
Contributor

I just cherry-picked this PR to the release/22.0 branch to get it included in the next release: 9704c13

@cbravobernal cbravobernal removed the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Nov 5, 2025
ellatrix added a commit that referenced this pull request Nov 5, 2025
…lates query when no slugs are left to find (#72795)"

This reverts commit ad996fb.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Template Registration: WooCommerce templates trigger PHP warning for sites using the FrontPage template

4 participants