Live Preview post-installation fails with multiple theme directories
|Reported by:||duck_||Owned by:||nacin|
If another theme directory is registered with register_theme_directory() then clicking Live Preview on the post-installation screen results in a "Cheatin' uh?" message.
Tested with a checkout of wpcom-themes in the wp-content directory with a one line plugin:
register_theme_directory( '/srv/http/wp.dev/public/wp-content/wpcom-themes' );
The problem is that get_theme_roots() returns the array stored in the theme_roots transient. This doesn't contain a value for the newly installed theme yet, so get_raw_theme_root() returns false. Therefore, wp_get_theme( 'newly-installed-theme' ) uses WP_CONTENT_DIR as the value for $theme_root. So, the returned WP_Theme has a theme_not_found error.
So, the theme exists check in WP_Customize_Manager::setup_theme() fails and a "Cheatin' uh?" message is displayed.
A possible solution is the trash the theme_roots site transient post install so that the next get_theme_roots() calls search_theme_directories().
This is spun out of ocean90's comment on #20914.