[wp-trac] [WordPress Trac] #50896: Add filters to wp_get_environment_type()

WordPress Trac noreply at wordpress.org
Thu Aug 13 14:28:50 UTC 2020


#50896: Add filters to wp_get_environment_type()
----------------------------+------------------------------
 Reporter:  crstauf         |       Owner:  (none)
     Type:  enhancement     |      Status:  new
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  Bootstrap/Load  |     Version:  5.5
 Severity:  normal          |  Resolution:
 Keywords:  has-patch       |     Focuses:
----------------------------+------------------------------

Comment (by crstauf):

 Replying to [comment:14 chesio]:
 > Environment type should be constant, it simply feels bad to think about
 it as a filterable value that can potentially change multiple times during
 single request.

 @chesio I agree: ideally, the environment type is set once and remains
 that same value. If it were not for the automatic setting of the
 `WP_DEBUG` constant, this could be done: define the `WP_ENVIRONMENT_TYPE`
 constant in an mu-plugin, and all's well. However (as I've mentioned
 previously, so forgive me if you've already read it and I'm now repeating
 for no value), given that the automatic setting of the `WP_DEBUG` in a
 production environment is most often innocuous (defined prior in `wp-
 config.php`), allowing the environment type to be filterable only by mu-
 plugins and then permanently set for the request I think is acceptable.

 Replying to [comment:14 chesio]:
 > I would argue that **production is the safest mode**. I would prefer any
 of my development websites to accidentally run in production mode than any
 of my production websites to accidentally run in development mode :-) In
 production HTTPS is forced, regular code integrity checks are run, assets
 are optimized etc...

 (Again, I've mentioned this previously, just not sure if you've read it;
 please forgive me if you have.)

 You are absolutely right: it is important that production run in
 production mode. It is equally important that development sites not run
 production-only code. Consider an API with a request cap or fees,
 automated sending out of emails, etc. Given that production is special and
 only one production environment exists, it is very likely that production
 will have been given special attention and that the `WP_ENVIRONMENT_TYPE`
 constant (and other important constants) defined in `wp-config.php`. Even
 if production were not special, there is still only one of them, so it's a
 "set it and forget it" situation. With development sites, there could be
 dozens (think local instances), and in my experience, very easy to forget
 to set the environment type before a single request is made to the local
 environment.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50896#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list