WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 6 weeks ago

#53599 new defect (bug)

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

Reported by: dd32 Owned by:
Milestone: 5.9 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 3 months ago.
Added patch.

Download all attachments as: .zip

Change History (3)

#1 @SergeyBiryukov
3 months ago

  • Milestone changed from Awaiting Review to 5.9

@opurockey
3 months ago

Added patch.

#2 @karpstrucking
6 weeks ago

  • Keywords has-patch added; needs-patch removed
Note: See TracTickets for help on using tickets.