[wp-trac] [WordPress Trac] #53599: WP_Theme::get_files() returns unexpected entry if parent theme not available.

WordPress Trac noreply at wordpress.org
Tue Jul 6 03:46:33 UTC 2021


#53599: WP_Theme::get_files() returns unexpected entry if parent theme not
available.
-------------------------+-------------------------------------------------
 Reporter:  dd32         |      Owner:  (none)
     Type:  defect       |     Status:  new
  (bug)                  |
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Themes       |    Version:
 Severity:  minor        |   Keywords:  needs-patch needs-unit-tests good-
  Focuses:               |  first-bug
-------------------------+-------------------------------------------------
 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

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53599>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list