Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dalepgrant opened this issue Apr 25, 2024 · 3 comments
Labels

Comments

@dalepgrant
Copy link

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 (roots/trellis@b791d54)

Log output

No response

Please confirm this isn't a support request.

Yes

@dalepgrant dalepgrant added the bug label Apr 25, 2024
@dalepgrant dalepgrant changed the title Introduction use Dotenv::createImmutable() breaks servers with multiple sites Introduction of "use Dotenv::createImmutable()" breaks servers with multiple sites Apr 25, 2024
@MWDelaney
Copy link
Member

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
Copy link
Author

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:

  • Start with two sites set up without changes from 💥 use Dotenv::createImmutable() #714, login to both.
  • Add changes to site 1 (in the screnshots, this is the right hand side), re-login as it signs you out
  • Add changes to site 2 (in the screenshots, this is the left hand side), visit wp-admin and see site 1 details shown.

Before

Screenshot 2024-05-02 at 9 33 09 am

After

Screenshot 2024-05-02 at 9 38 54 am

@dalepgrant
Copy link
Author

dalepgrant commented May 2, 2024

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 🙏

@dalepgrant dalepgrant closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants