roots / bedrock

WordPress boilerplate with Composer, easier configuration, and an improved folder structure
https://roots.io/bedrock/
MIT License
6.15k stars 1.16k forks source link

Introduction of "use Dotenv::createImmutable()" breaks servers with multiple sites #718

Closed dalepgrant closed 4 months ago

dalepgrant commented 4 months ago

Version

714

What did you expect to happen?

Retain the ability to host multiple sites on one server.

What actually happens?

The changes introduced in #714 cause havoc, the best way I can describe it is that domain2.com starts trying to use domain1.com's database.

Steps to reproduce

Deploy two Bedrock sites on the same server at different URLs Change the settings in WP Admin of both sites (anything, active themes, active plugins, Site name, whatever) One site will take the values of the other Remove the changes from #714 Note that both sites gain their independence again.

System info

Ubuntu 22.04 provisioned with Trellis (https://github.com/roots/trellis/commit/b791d54e8f6c9dcc5a909a51d9368136cf04f455)

Log output

No response

Please confirm this isn't a support request.

Yes

MWDelaney commented 4 months ago

Hi, I cannot reproduce this issue in a testing environment. Can you tell us more about your configuration?

Here are the steps I took to reproduce:

  1. Create a new Trellis instance
  2. Duplicate the site directory, call it second_site
  3. Update production wordpress_sites.yml and vault.yml adding a second site to each, changing the key, url, and subtree path as necessary
  4. Provision production
  5. Deploy first site
  6. Deploy second site
  7. Set up WordPress and log into each.
  8. Make a change on the first site (change the "styles" of the default theme).

The change was NOT reflected on the second site. This issue was not reproduced.

So can you tell us more?

dalepgrant commented 4 months ago

Thanks for checking @MWDelaney 🙏 I've been meaning to come back with more info as I know I wrote this report super quick.

I didn't realise but I can actually replicate this in my local. I will try to get a repeatable demo up for you to check, but all I have to do to trigger this is add the change from #714 into two sites and it goes haywire.

I'll come back to add more, but here's some screenshots to show what I'm seeing and the steps I took:

Before

Screenshot 2024-05-02 at 9 33 09 am

After

Screenshot 2024-05-02 at 9 38 54 am
dalepgrant commented 4 months ago

I've narrowed this down to usage with Redis, can reproduce consistently with a test setup.

Scratch that. In prepping the repo for someone to look at and reproduce, I've found the error of my ways. 🤦‍♂️

We were using Config::define('WP_CACHE_KEY_SALT', getenv('DB_NAME')); to avoid conflicts with dbs when using Redis. The getenv() turned out to be the issue. Change to env() and voila, no more issues. Should have read the issue notes more clearly, it does say about getenv() (and putenv()).

I'll leave the repo up, maybe it'll help someone else. Thanks for looking at this 🙏