bedrock icon indicating copy to clipboard operation
bedrock copied to clipboard

Use the new constant WP_ENVIRONMENT_TYPE

Open ArnaudBan opened this issue 4 years ago • 7 comments

Summary

WordPress 5.5 introduce environment.I think it could be a good idea to use the new variable WP_ENVIRONMENT_TYPE instead of WP_ENV

Motivation

User are still going to add the new WP_ENVIRONMENT_TYPE so we are going to have two constant that have the same purpose.

ArnaudBan avatar Jul 28 '20 06:07 ArnaudBan

I'm having some doubts here. I mean - having those separate is a bit strange, don't you think?

Or maybe we should set it like this: if no WP_ENVIRONMENT_TYPE is set we should set WP_ENVIRONMENT_TYPE to be the same as WP_ENV.

Or should they always be separated?

palmiak avatar Jul 30 '20 12:07 palmiak

Yes we'd likely support both transparently. So we'd set WP_ENVIRONMENT_TYPE according to WP_ENV and vice versa.

However, I think there's still hope that the wp_get_environment_type function will check WP_ENV as well.

swalkinshaw avatar Jul 30 '20 13:07 swalkinshaw

Looking at this https://core.trac.wordpress.org/ticket/33161 - I don't think there is hope for WP_ENV :/

But aside - so in short:

  • if both are defined - we just define theme as they are
  • if only one is defined we define as the second one

I can do a PR for this.

palmiak avatar Jul 30 '20 13:07 palmiak

Before I would push a PR - could you take a look:

Config::define('WP_ENVIRONMENT_TYPES', env('WP_ENVIRONMENT_TYPES') ? explode(',', env('WP_ENVIRONMENT_TYPES')) : ['production', 'staging', 'development']);

if (env('WP_ENV') || env('WP_ENVIRONMENT_TYPE')) {
    Config::define('WP_ENV', env('WP_ENV') ?: env('WP_ENVIRONMENT_TYPE'));
    Config::define('WP_ENVIRONMENT_TYPE', env('WP_ENVIRONMENT_TYPE') ?: env('WP_ENV'));
    define('WP_ENV', env('WP_ENV') ?: env('WP_ENVIRONMENT_TYPE'));
} else {
    Config::define('WP_ENV', 'production');
    define('WP_ENV', 'production');
}

I also prepared the WP_ENVIRONMENT_TYPES - I think it covers all the cases.

palmiak avatar Jul 30 '20 20:07 palmiak

@palmiak thank you! want to push a PR and i can tag some people to review over there?

retlehs avatar Aug 12 '20 04:08 retlehs

Just wanted to make sure it solid - I'll prepare the PR soon

śr., 12 sie 2020, 06:22 użytkownik Ben Word [email protected] napisał:

@palmiak https://github.com/palmiak thank you! want to push a PR and i can tag some people to review over there?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/roots/bedrock/issues/538#issuecomment-672563940, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR34OTUN66UZ7JQ62ZOBU3SAIKIFANCNFSM4PKF6NCA .

palmiak avatar Aug 12 '20 06:08 palmiak

Of note, 5.5.1 added local as an option (thankfully). link

jameelmoses avatar Sep 02 '20 14:09 jameelmoses

https://github.com/roots/bedrock/pull/668

retlehs avatar Feb 17 '23 03:02 retlehs