Make WordPress Core

Opened 14 months ago

Closed 10 months ago

Last modified 10 months ago

#40820 closed defect (bug) (fixed)

Child theme should appear as broken if parent is itself

Reported by: davilera Owned by: swissspidy
Milestone: 4.9 Priority: normal
Severity: minor Version: 4.7.5
Component: Themes Keywords: has-patch has-unit-tests
Focuses: Cc:


Child themes are defined as such if they include the Template header in style.css. In general, if the parent template can't be found, WordPress reports the theme as Broken and tells the user to install the missing parent theme.

However, if the Template header is the theme itself, no errors are reported (WordPress can find the "parent" theme, because it's itself). The resulting behavior is weird and unexpected:

  • If there are other themes available, WordPress uses one as the parent theme (I don't know which criteria is used for selecting one or the other).
  • If there aren't, the front-end is completely blank (but this might depend on the amount of code included in the child theme).

Such an (invalid) child theme should be reported as Broken. For instance, the following message could be shown: The theme defines itself as its parent theme. Please fix the "Template" header.

Attachments (3)

40820_fix_proposal.diff (840 bytes) - added by davilera 14 months ago.
Adds an extra check to make sure that the parent theme of a child theme is not the child theme itself.
40820.diff (2.2 KB) - added by davilera 13 months ago.
40820.2.diff (2.7 KB) - added by swissspidy 10 months ago.

Download all attachments as: .zip

Change History (12)

14 months ago

Adds an extra check to make sure that the parent theme of a child theme is not the child theme itself.

#1 @davilera
14 months ago

  • Keywords has-patch needs-testing added
  • Resolution set to invalid
  • Severity changed from normal to minor
  • Status changed from new to closed

#2 @davilera
14 months ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

13 months ago

#3 @davilera
13 months ago

  • Focuses template removed
  • Keywords has-unit-tests added

I just uploaded a new patch 40820.diff along with a Unit Test.

#4 @swissspidy
13 months ago

  • Owner set to swissspidy
  • Status changed from reopened to reviewing

#5 @swissspidy
13 months ago

  • Keywords needs-testing removed
  • Milestone changed from Awaiting Review to 4.9

40820.2.diff is an updated patch that adjusts other theme unit tests because of that new test theme.

10 months ago

#6 @swissspidy
10 months ago

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

In 41601:

Themes: Report theme as broken that sets itself as its parent.

Props davilera.
Fixes #40820.

#7 @obenland
10 months ago

@swissspidy What do you think about setting Template in <code> tags?

#8 @swissspidy
10 months ago

In 41607:

Themes: Adjust translated string after [41601].

Props obenland.
See #40820.

#9 @swissspidy
10 months ago

In 41610:

Themes: Adjust unit test after [41607].

Props ocean90.
See #40820.

Note: See TracTickets for help on using tickets.