Update WP theme paths - what does this hook do?

I am wondering what possible side-effects could occur by removing this hook. For some reason, when I updated all my sites to 4.7 last week, all of my widgets were set to inactive. I then determined it was this role causing the problem.

- name: Update WP theme paths
  command: wp eval 'wp_clean_themes_cache(); switch_theme(get_stylesheet());'
  args:
    chdir: "{{ deploy_helper.new_release_path }}"
  when: wp_installed | success

My theme is a composer dep. of my Bedrock site, which I believe is not recommended, so that may be the root cause of the issue. I’m just trying to figure out if commenting out this hook will have any detrimental effect down the road.

Background:

Thanks, now I know what to look out for after removing it. Now I am just wondering if I am on the right track - that my issue is caused by my theme being a composer dependency. I am just assuming this is the case because others using the Roots stack do not appear to have this problem. The odd thing is that I have only ever seen this problem pop up after major releases for WP. First I thought it would be because my theme files would not be in place during the database update, so WordPress would see the theme as missing at that point in time, and make the widgets inactive. But reading over the deployment files it looks like the composer deps should be installed prior to the database update (duh… because WP itself is a dep)… but now I am at a loss as to the cause again.

Going to do some more testing, it is just very tedious since I need to rollback and restore the database from backup each time.

Thanks for the point in the right direction though!

I discovered that moving this hook to run after the DB update hook seems to resolve the problem. I am guessing the reason I have anecdotally associated this with major WP releases is due to the database changes that are usually associated with major versions. I still cannot trace this back to an exact root cause (which is annoying), but it is working now and for productivity’s sake I must move on. Would love to hear from anyone else who experienced this or has any insights into what might be happening.

I am thinking that running this hook after the DB update would be preferable anyway. Since 2 functions are being evaluated it is possible they are expecting a different database schema. The functions would be from the updated WP Core, but the database would still be in a state that reflects the previous WP Core version. I would think this could lead to possible issues. I am not confident enough in my assumption to make a PR though.

I’ve updated the deploy hook with a better method which should fix these problems: https://github.com/roots/trellis/pull/720

1 Like