Skip to content

Conversation

@ellatrix
Copy link
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
Copy link

github-actions bot commented Oct 29, 2025

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 <[email protected]>
Co-authored-by: Aljullu <[email protected]>
Co-authored-by: kmanijak <[email protected]>
Co-authored-by: bacoords <[email protected]>

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 Pull request that needs to be backported to the WordPress major release that's currently in beta Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) labels Oct 29, 2025
Copy link
Contributor

@Aljullu Aljullu left a comment

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

Copy link
Contributor

@kmanijak kmanijak left a comment

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
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
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
@github-actions github-actions bot removed the Backport to WP 6.9 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label 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 <[email protected]>
Co-authored-by: Aljullu <[email protected]>
Co-authored-by: kmanijak <[email protected]>
Co-authored-by: bacoords <[email protected]>
@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

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 <[email protected]>
Co-authored-by: Aljullu <[email protected]>
Co-authored-by: kmanijak <[email protected]>
Co-authored-by: bacoords <[email protected]>
@cbravobernal
Copy link
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

5 participants