Make WordPress Core

Opened 7 months ago

Last modified 2 months ago

#53599 assigned defect (bug)

WP_Theme::get_files() returns unexpected entry if parent theme not available.

Reported by: dd32 Owned by: hellofromTonya
Milestone: 6.0 Priority: normal
Severity: minor Version:
Component: Themes Keywords: needs-unit-tests good-first-bug has-patch
Focuses: Cc:

Description

Given the following code, you'll get a slightly unexpected output if the parent theme is not available.

$theme = new WP_Theme( ... );
$files = $theme->get_files(
	null /* all file types */,
	-1 /* infinite recursion */,
	true /* include parent theme files */
);
var_dump( $files );

Expected output:

wp-content/plugins/example/example.php:4:
array (size=1)
  'index.php' => string '/tmp/test-theme/index.php' (length=25)

Actual output:

wp-content/plugins/example/example.php:4:
array (size=2)
  'index.php' => string '/tmp/test-theme/index.php' (length=25)
   0 => boolean false

I believe the inclusion of 0 as the filename, and false as the path is rather unexpected

Attachments (1)

53599.patch (650 bytes) - added by opurockey 6 months ago.
Added patch.

Download all attachments as: .zip

Change History (7)

#1 @SergeyBiryukov
7 months ago

  • Milestone changed from Awaiting Review to 5.9

@opurockey
6 months ago

Added patch.

#2 @karpstrucking
5 months ago

  • Keywords has-patch added; needs-patch removed

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


3 months ago

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


2 months ago

#5 @hellofromTonya
2 months ago

  • Milestone changed from 5.9 to 6.0
  • Owner set to hellofromTonya
  • Status changed from new to assigned

I wasn't able to reproduce the problem. As this also needs tests, assigning ownership to me to investigate and get the tests done. Moving to 6.0 as 5.9 Beta 1 is tomorrow and this needs more time to get it ready.

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


2 months ago

Note: See TracTickets for help on using tickets.