Make WordPress Core

Opened 3 weeks ago

Closed 2 weeks ago

Last modified 8 days ago

#63062 closed defect (bug) (fixed)

Parent theme incorrectly not getting resolved in WordPress 6.8-beta1

Reported by: fabiankaegy's profile fabiankaegy Owned by: joemcgill's profile joemcgill
Milestone: 6.8 Priority: high
Severity: normal Version: trunk
Component: Themes Keywords: has-patch needs-unit-tests needs-testing has-testing-info has-screenshots
Focuses: Cc:

Description

I just installed 6.8-beta1 on a site that is using a child theme and noticed that it's parent theme is no longer getting resolved. The themes both still appears in the themes listing but the child theme shows that it is broken because the parent theme is missing.

Downgrading to 6.7.2 resolves the issue again.

I was able to reproduce it with the most bare child theme possible off of a core theme.

Attachments (17)

child.zip (2.0 KB) - added by fabiankaegy 3 weeks ago.
Most basic version of a child theme with which I am able to reproduce the issue
CleanShot 2025-03-05 at 18.19.26@2x.png (869.7 KB) - added by fabiankaegy 3 weeks ago.
Before fix - error notice.jpg (441.7 KB) - added by krupajnanda 3 weeks ago.
after fix - no error.jpg (530.9 KB) - added by krupajnanda 3 weeks ago.
issue_with_child_theme.png (616.6 KB) - added by navi161 3 weeks ago.
child_theme_error_fix.png (3.2 MB) - added by navi161 3 weeks ago.
error_fix.mov (841.0 KB) - added by navi161 3 weeks ago.
beforePatch.jpeg (740.8 KB) - added by manojmaharrshi 3 weeks ago.
Before Patch Snapshot
afterPatch.png (969.6 KB) - added by manojmaharrshi 3 weeks ago.
After Patch Snapshot
Before Fix.png (238.7 KB) - added by Ankit K Gupta 3 weeks ago.
after fix.png (241.4 KB) - added by Ankit K Gupta 3 weeks ago.
storefront-child.zip (1007 bytes) - added by Ankit K Gupta 3 weeks ago.
twentytwentyfive-child.zip (1.0 KB) - added by Ankit K Gupta 3 weeks ago.
TT5 Child theme
beforePatch.2.jpeg (740.8 KB) - added by narenin 3 weeks ago.
Before applying patch
afterPatch.2.png (969.6 KB) - added by narenin 3 weeks ago.
After applying patch
before-patch.png (145.8 KB) - added by shailu25 3 weeks ago.
Before Patch.
after-patch.png (133.2 KB) - added by shailu25 3 weeks ago.
After Patch.

Change History (54)

@fabiankaegy
3 weeks ago

Most basic version of a child theme with which I am able to reproduce the issue

#1 @joemcgill
3 weeks ago

  • Owner set to joemcgill
  • Status changed from new to reviewing

This ticket was mentioned in PR #8466 on WordPress/wordpress-develop by @joemcgill.


3 weeks ago
#2

  • Keywords has-patch has-unit-tests added

#3 @joemcgill
3 weeks ago

  • Keywords has-patch has-unit-tests removed
  • Priority changed from normal to high
  • Status changed from reviewing to accepted
  • Version set to trunk

Using git-bisect, it looks like this regression was introduced in [59885]. I'm guessing that calling wp_is_block_theme() this early is likely polluting the cache prior to themes being set up.

I've created a PR that reverts that commit for testing, but we should find a way to fix this without fully reverting the commit that fixed #61811.

#4 @joemcgill
3 weeks ago

  • Keywords has-patch needs-unit-tests needs-testing added

#5 @joemcgill
3 weeks ago

Updated the PR with a small fix. Hoping to get some tests added and consider whether we want to address the root cause rather than just this bug. I've left more details in the PR.

This ticket was mentioned in Slack in #core by jeffr0. View the logs.


3 weeks ago

#7 @jeffr0
3 weeks ago

Thank you for reporting this issue @fabiankaegy I too encountered this today after installing 6.8 Beta 1 while using a Child theme.

#8 @krupajnanda
3 weeks ago

  • Keywords has-testing-info has-screenshots added

Test Report

Description

I verified the PR with Playground and shared child theme zip and looks like it is working as expected now.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/8466

Environment

  • WordPress: 6.8-beta1-20250305.214555
  • PHP: 7.4.31-dev
  • Server: PHP.wasm
  • Database: WP_SQLite_Translator (Server: 5.5 / Client: 3.40.1)
  • Browser: Chrome 133.0.0.0
  • OS: macOS
  • Theme: Minimal Child Theme 1.0.2
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Actual Results

  1. ✅ Issue resolved with patch.

Supplemental Artifacts

Add as Attachment

Last edited 3 weeks ago by krupajnanda (previous) (diff)

This ticket was mentioned in Slack in #core-test by krupajnanda. View the logs.


3 weeks ago

#10 @riddhidave
3 weeks ago

Ticket Reference: Issue with Parent Theme Resolution in WordPress 6.8-beta1

Before the patch screenshot
https://tinyurl.com/2c5dduqp
After Patch screenshot
https://tinyurl.com/24wu4q2q

Issue Summary: installing WordPress 6.8-beta1 on a site using a child theme, it was observed that the parent theme was no longer being resolved. The child theme appeared broken in the themes listing, displaying the error:

Error: The parent theme is missing. Please install the "twentytwentyfive" parent theme.

However, downgrading to WordPress 6.7.2 resolved the issue, restoring the child theme’s functionality.

Steps to Reproduce (Before Patch):

Install WordPress 6.8-beta1.

Set up a child theme that depends on a core theme (e.g., twentytwentyfive).

Navigate to the WordPress admin panel under Appearance > Themes.

Observe that the child theme is marked as broken with the above-mentioned error.

Expected Behavior (Before Patch):

The child theme should correctly recognize its parent theme and function normally.

Actual Behavior (Before Patch):

The parent theme was not being detected.

The child theme was marked as broken and unusable.

Testing After Applying the Patch:

Updated WordPress to the patched version.

Retested with the same child theme setup.

Observed that the child theme now correctly recognizes its parent theme.

Verified that the error message no longer appears and the child theme is fully functional.

Results (After Patch):

The issue is successfully resolved.

The child theme correctly inherits from the parent theme as expected.

No error messages were displayed.

Conclusion:
The applied patch effectively fixes the parent theme resolution issue introduced in WordPress 6.8-beta1. After testing, the child theme is now working properly without any errors.

#11 @ugyensupport
3 weeks ago

Parent theme incorrectly not getting resolved in WordPress 6.8-beta1

Description

I just installed 6.8-beta1 on a site that is using a child theme and noticed that it's parent theme is no longer getting resolved. The themes both still appears in the themes listing but the child theme shows that it is broken because the parent theme is missing.

Downgrading to 6.7.2 resolves the issue again.
According to @fabiankaegy, able to reproduce it with the most bare child theme possible off of a core theme.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/8466

Environment

  • WordPress: 6.8-beta1-59940
  • PHP: 8.4.1
  • Server: Apache/2.4.62 (Unix) mod_wsgi/5.0.1 Python/3.12 mod_fastcgi/mod_fastcgi-SNAP-0910052141 OpenSSL/1.1.1w
  • Database: WP_SQLite_DB\PDOEngine (Server: 3.47.0 / Client: 3.47.0)
  • Browser: Chrome 133.0.0.0
  • OS: macOS
  • Theme: Minimal Child Theme 1.0.2
  • MU Plugins: None activated
  • Plugins:
    • Child Theme Configurator 2.6.6
    • Test Reports 1.2.0
    • WP File Manager 8.0.1

Actual Results

  1. ✅ Issue resolved with patch.

Supplemental Artifacts

Before: https://limewire.com/?referrer=pq7i8xx7p2

After: https://limewire.com/?referrer=pq7i8xx7p2

#12 @navi161
3 weeks ago

Test Report

This report validates that the indicated patch addresses the issue.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/8466

Environment

  • OS: macOS 14.6.1
  • Web Server: PHP.wasm
  • PHP: 7.4.31-dev
  • WordPress: 6.8-beta1-20250305.214555
  • Browser: Chrome Version 133.0.6943.142
  • Theme: Minimal Child Theme Version 1.0.2

Actual Results

  • ✅ Issue resolved with patch.

Reference Screens Attached.

@navi161
3 weeks ago

#13 @manojmaharrshi
3 weeks ago

Test Report

Description

This report validates whether the indicated patch for the child theme.

Patch tested: https://patch-diff.githubusercontent.com/raw/WordPress/wordpress-develop/pull/8466.diff

Environment

  • WordPress: 6.8-beta1-59933-src
  • PHP: 8.2.27
  • Server: nginx/1.27.4
  • Database: mysqli (Server: 8.4.4 / Client: mysqlnd 8.2.27)
  • Browser: Chrome 133.0.0.0
  • OS: macOS
  • Theme: Minimal Child Theme 1.0.2
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Actual Results

  1. ✅ Issue resolved with patch.

@manojmaharrshi
3 weeks ago

Before Patch Snapshot

@manojmaharrshi
3 weeks ago

After Patch Snapshot

#14 @Ankit K Gupta
3 weeks ago

Tested Additional Use Cases Apart from the Above-Listed Test Reports

  • Since the issue was related to a Block-based theme, verified the fixes with a Non-Block-based theme like Storefront to check regression. Everything worked as expected ✅
  • Verified behavior when the parent theme is not installed (or deleted) while the child theme is still present. A message correctly appeared: _"The active theme is broken. Reverting to the default theme."_ ✅
  • Before the fix: The WP-CLI command (wp theme list) did not show the child theme in the theme list. After the fix: Verified that the child theme is now correctly listed. (Screenshots attached) ✅
  • Tested via created Block-based (Twenty Twenty-Five) Child theme and Non-Block-based (Storefront) child themes to ensure compatibility. ✅
  • Backward Compatibility: Reverted back to WordPress 6.7.2 after using the fix-specific branch. No issues appeared. ✅
  • Attached child theme zip for TT5 and Storefront for further testing. ℹ
  • No related console error or PHP errors observed while testing above use cases. ✅
  • Full Site Editing works when Child theme is installed and active ✅

Before Fix: https://prnt.sc/W8P0mfiMiGZ9
After Fix: https://prnt.sc/2VlTiXuessjY

@Ankit K Gupta
3 weeks ago

TT5 Child theme

#15 @narenin
3 weeks ago

Test Report

This report validates that the indicated patch addresses the issue.

Patch tested:

https://github.com/WordPress/wordpress-develop/pull/8466

Environment

OS: macOS 14.6.1
Web Server: PHP.wasm
PHP: 7.4.31-dev
WordPress: 6.8-beta1-20250305.214555
Browser: Chrome Version 133.0.6943.142
Theme: Minimal Child Theme Version 1.0.2

Actual Results

✅ Issue resolved with patch.

@narenin
3 weeks ago

Before applying patch

@narenin
3 weeks ago

After applying patch

@audrasjb commented on PR #8466:


3 weeks ago
#16

I tested this PR and it seems to fix the issue.

Before applying the PR:
before-applying-the-PR.webm

After applying the PR:
after-applying-the-PR.webm

@audrasjb commented on PR #8466:


3 weeks ago
#17

I tested this PR and it seems to fix the issue.

Before applying the PR:
before-applying-the-PR.webm

After applying the PR:
after-applying-the-PR.webm

#18 @audrasjb
3 weeks ago

👆 Note: the above comment (17) is not related to this ticket/PR.

#19 @pooja1210
3 weeks ago

Hi,

Test Report:

Verified the fix on the attached theme with the patch, and it is working fine. Able to activate the theme successfully.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/8466

Environment
WordPress: 6.8-beta1-2025030
OS: macOS
Theme: Minimal Child Theme

Actual Result: The fix is working properly, and the theme can be activated.

Screenshots:
Before fix: https://prnt.sc/__bk9MWO1xx2
After fix: https://prnt.sc/VR7Uj-ODliIo

Thanks

#20 @shailu25
3 weeks ago

Test Report

Patch Tested: https://github.com/WordPress/wordpress-develop/pull/8466

Environment:
WordPress - 6.8-beta1
OS - Windows
Browser - Firefox
Theme: Minimal Child Theme
PHP - 8.2.12
Active Plugin: None

Actual Results:

  • Issue Resolved With Patch.✅

Screenshots:

  • Added Attachment

@shailu25
3 weeks ago

Before Patch.

@shailu25
3 weeks ago

After Patch.

@joemcgill commented on PR #8466:


2 weeks ago
#21

I've updated the logic here to move setting post type support to a standalone callback, as suggested in this comment. @peterwilsoncc any chance you can take another look at this before beta 2?

#22 @joemcgill
2 weeks ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 59968:

Themes: Fix resolution of parent themes.

This fixes an issue introduced in [59885] whereby calling WP_Theme:is_block_theme() before themes are set up resulted in the parent theme to not be resolved. To address this, post support for editor default-mode has been moved to a standalone callback, wp_set_editor_default_mode(), which is called on the after_setup_theme hook. In addition, if WP_Theme::is_block_theme is called too early, a _doing_it_wrong() error will now be thrown.

Props fabiankaegy, joemcgill, peterwilsoncc, jorbin, krupajnanda, riddhidave, ugyensupport, navi161, manojmaharrshi, Ankit K Gupta, narenin, shailu25, pooja1210.
Fixes #63062.

This ticket was mentioned in Slack in #core by krupajnanda. View the logs.


2 weeks ago

#25 @wildworks
2 weeks ago

Due to the influence of the _doing_it_wrong, it seems that the customizer displays a warning. See https://core.trac.wordpress.org/ticket/63086

#26 @wildworks
2 weeks ago

In addition, if WP_Theme::is_block_theme is called too early, a _doing_it_wrong() error will now be thrown.

This early return might cause problems if you have a theme or plugin that is calling WP_Theme::is_block_theme too early.

For example, if the following plugin is enabled:

<?php
/**
 * Plugin Name: Block Theme Test
 */

wp_is_block_theme();

At this time, the site editor appears to display a black screen.

#27 @wildworks
2 weeks ago

Another example: In some cases, the submenu in the Appearance menu may change from Editor to Design, making the site editor itself inaccessible.

See https://github.com/WordPress/gutenberg/pull/69542

This ticket was mentioned in Slack in #core by mamaduka. View the logs.


2 weeks ago

#29 @gigitux
2 weeks ago

Thanks, @wildworks, for the initial exploration. As mentioned in [63086], this change causes regressions in plugins relying on wp_is_block_theme(), such as WooCommerce.

Based on the discussion, this change seems necessary because wp_is_block_theme() may return an incorrect value due to inaccurate parent theme resolution before after_setup_theme. A potential solution could be addressing the parent theme resolution issue.

After some investigation (cc @nerrad), we found:

  • wp_is_block_theme() calls wp_get_theme() to retrieve the theme and invokes the is_block_theme() method.
  • wp_get_theme() instantiates WP_Theme, which sets a cache on the first run. If executed before after_setup_theme, the theme's functions.php will not have been processed, resulting in an incorrect cache.

A possible solution could be to only set the cache on WP_Theme if instantiated after after_setup_theme; otherwise, avoid caching.

It is essential to take careful consideration of performance implications.

#30 @dinhtungdu
12 days ago

Digging deeper into the Core to understand the issue, I found that:

  • wp_is_block_theme doesn't need to be called after after_theme_setup, it just needs to be called after theme directories registration.
  • The initial issue with the child theme is caused by calling that function after creating post types, which is before the theme directories registration.
  • Moving that logic to after_theme_setup, as we did in this ticket, is enough to solve the issue.
  • Plugins can never break the theme resolution because they are loaded after theme directories registration.

So the warning and early return don't protect us from anything and should be removed.

This ticket was mentioned in Slack in #core-committers by nerrad. View the logs.


12 days ago

This ticket was mentioned in PR #8508 on WordPress/wordpress-develop by @dinhtungdu.


12 days ago
#32

This PR partially reverts https://core.trac.wordpress.org/changeset/59968 by removing the warning and early return in WP_Theme::is_block_theme(), which causes issues if active plugins call wp_is_block_theme() early. It's safe for plugins to call wp_is_block_theme() anytime so the early return and warning should be removed.

Trac ticket: https://core.trac.wordpress.org/ticket/63062

#33 @afragen
10 days ago

FWIW is_block_theme() is called in the constructor for WP_Theme and this error and early return is causing loads of issues in plugins because of that.

@afragen commented on PR #8508:


10 days ago
#34

Absolutely agree. This is filling up my logs and not sure it's even effecting function.

#35 @joemcgill
9 days ago

Hi all, I appreciate everyone's testing and feedback so far! #63086 is tracking the _doing_it_wrong() placement. Let's consolidate further conversation over there to try to keep things in one place.

@dinhtungdu commented on PR #8508:


8 days ago
#36

Closing in favor of #8526

#37 @joemcgill
8 days ago

In 60037:

Themes: Improve error notice when wp_is_block_theme() is called too early.

This is a follow-up to [59968] which improves error handling for when wp_is_block_theme() is called too early. Initially, _doing_it_wrong() was called in WP_Theme::is_block_theme() was called prior to themes being set up, in order to avoid the bug reported in #63062, where doing so would cause parent themes to not be resolved. After further investigation, the issue is only caused by calling wp_is_block_theme() before the root theme directory has been registered (e.g., when called on the muplugins_loaded hook).

Moving This error message to wp_is_block_theme() when $GLOBALS['wp_theme_directories'] is empty avoids unnecessary error messages.

Props wildworks, sukhendu2002, SirLouen, dinhtungdu, narenin, joemcgill, peterwilsoncc, afragen.
Fixes #63086. See #63062.

Note: See TracTickets for help on using tickets.