[wp-trac] [WordPress Trac] #50896: Add filters to wp_get_environment_type()
WordPress Trac
noreply at wordpress.org
Tue Aug 11 15:28:03 UTC 2020
#50896: Add filters to wp_get_environment_type()
-------------------------+------------------------------
Reporter: crstauf | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses:
-------------------------+------------------------------
Old description:
> When first introduced and described on
> [https://make.wordpress.org/core/2020/07/24/new-wp_get_environment_type-
> function-in-wordpress-5-5/ the Make blog] by Yoast, the function
> contained filters. These filters were removed in
> [https://core.trac.wordpress.org/changeset/48662 48662] because "the
> function is called too early for any plugins to properly hook into these
> filters".
>
> The only _current_ use of `wp_get_environment_type()` by core is for
> setting the `WP_DEBUG` constant when in a development environment. While
> it's true that filters won't work in that scenario, the filters would be
> useful for themes and plugins.
>
> In my case, I want to set the default environment to "development": while
> there's only one production environment, there are multiple development
> environments that can be created at any time. Setting the environment
> default to "development" means that whenever a new development
> environment is created, the code runs in its safest mode from the start,
> even without explicitly defining `WP_ENVIRONMENT_TYPE` constant.
>
> Reverting [https://core.trac.wordpress.org/changeset/48662 48662] would
> close this ticket.
New description:
When first introduced and described on
[https://make.wordpress.org/core/2020/07/24/new-wp_get_environment_type-
function-in-wordpress-5-5/ the Make blog] by Yoast, the function contained
filters. These filters were removed in
[https://core.trac.wordpress.org/changeset/48662 48662] because "the
function is called too early for any plugins to properly hook into these
filters".
The only _current_ use of `wp_get_environment_type()` by core is for
setting the `WP_DEBUG` constant when in a development environment. While
it's true that filters won't work in that scenario, the filters would be
useful for themes and plugins.
In my case, I want to set the default environment to "development": while
there's only one production environment, there are multiple development
environments that can be created at any time. Setting the environment
default to "development" means that whenever a new development environment
is created, the code runs in its safest mode from the start, even without
explicitly defining `WP_ENVIRONMENT_TYPE` constant.
Reverting [48662] would close this ticket.
--
Comment (by SergeyBiryukov):
Hi there, welcome back to WordPress Trac!
> When first introduced and described on
[https://make.wordpress.org/core/2020/07/24/new-wp_get_environment_type-
function-in-wordpress-5-5/ the Make blog] by Yoast, the function contained
filters. These filters were removed in [48662] because "the function is
called too early for any plugins to properly hook into these filters".
> ...
> Reverting [48662] would close this ticket.
Just noting that simply reverting [48662] won't work as expected. As
previously noted in comment:58:ticket:33161, the result of the function is
cached into a static variable (per comment:44:ticket:33161) on the first
run (which is too early for filters), and cannot be changed later.
So we'll also have to remove the static variable, which may lead to
issues, as noted in comment:44:ticket:33161.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50896#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list