[wp-trac] [WordPress Trac] #19244: get_theme() function incorrectly assuming $themes is always an array

WordPress Trac wp-trac at lists.automattic.com
Mon Nov 14 23:29:43 UTC 2011


#19244: get_theme() function incorrectly assuming $themes is always an array
--------------------------+-----------------------------
 Reporter:  cgrymala      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Themes        |    Version:  3.3
 Severity:  normal        |   Keywords:  has-patch
--------------------------+-----------------------------
 On line 499 of the current /wp-includes/theme.php file, within the
 get_theme() function, the array_key_exists() function is being run on the
 $themes variable, which may not always be an array. If it's not an array,
 the get_theme() function will throw a PHP warning (which, depending on the
 user's PHP settings, could also throw additional errors about the headers
 not being able to be set because of previous output).

 The $themes variable is populated from the get_themes() function, which
 may return an array, or may return boolean false (if
 search_theme_directories() returns false to the get_themes() function).

 I would propose that either get_themes() be modified to always return an
 array, or that get_theme() be modified to check the data type of the
 $themes variable before attempting to use the array_key_exists() function.
 I've attached a patch with the latter suggestion implemented. Thanks.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19244>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list