Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
WSOD with status 200 after deploy (only if you do not navigate to wp-admin or re-activate theme)
Setup
Deploy 1 -- no problem yet
Deploy 2 -- here's the WSOD problem due to out-of-date "theme roots" in db
Deploy 3 -- same WSOD, incorrect deploy 1 release path in db -- should be deploy 3 release path
Potential solution
This PR adds
project_post_finalize_commands
that...wp_clean_themes_cache()
switch_theme()
to the current themeDeploy 4 -- no more WSOD problem
What's happening
Capistrano-style deploys have had trouble with out-of-date theme roots in the db, leading to a white screen. Some have addressed the issue by running a conditional search-replace on the
stylesheet_root
andtemplate_root
in the db.However, it seems cleaner to run
switch_theme()
to the current theme, which will refresh thewp_option
values forstylesheet_root
andtemplate_root
. It does so viaget_raw_theme_root()
, which consultsget_theme_roots()
, which tries to useget_site_transient( 'theme_roots' )
, which consults awp_options
transient named_site_transient_theme_roots
.This
_site_transient_theme_roots
contains absolute paths that don't update on deploy, so it points to out-of-date release directories. But, as in wp theme unit tests, if we 'wp_clean_themes_cache()', theget_theme_roots()
above willsearch_theme_directories( true ); // Regenerate the transient
, getting the release path of the latest deploy, adding it tostylesheet_root
andtemplate_root
.Any of you WP pros see any problems with this? Recommend a better solution?