get_theme() function incorrectly assuming $themes is always an array
|Reported by:||cgrymala||Owned by:||nacin|
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.
Change History (8)
- Keywords needs-patch added; has-patch removed
- Milestone changed from Awaiting Review to Future Release
- Version changed from 3.3 to 3.2.1