Ticket #33161: 33161.diff
File 33161.diff, 2.3 KB (added by , 3 years ago) |
---|
-
src/wp-includes/load.php
142 142 * @return string The current environment type. 143 143 */ 144 144 function wp_get_environment_type() { 145 $ approved_environments = array(145 $wp_environments = array( 146 146 'development', 147 147 'stage', 148 148 'production', 149 149 ); 150 150 151 // Check if the environment variable has been set, if `getenv` is available on the system. 152 if ( function_exists( 'getenv' ) ) { 153 $has_env = getenv( 'WP_ENVIRONMENT_TYPES' ); 154 if ( false !== $has_env ) { 155 $wp_environments = explode( ',', $has_env ); 156 } 157 } 158 159 // Fetch the environment types from a constant, this overrides the global system variable. 160 if ( defined( 'WP_ENVIRONMENT_TYPES' ) ) { 161 $wp_environments = WP_ENVIRONMENT_TYPES; 162 } 163 151 164 /** 152 * Filters the list of approved environment types.165 * Filters the list of supported environment types. 153 166 * 154 167 * This filter runs before it can be used by plugins. It is designed for non-web runtimes. 155 168 * 156 169 * @since 5.5.0 157 170 * 158 * @param string $approved_environments The list of approvedenvironment types. Possible values159 * 171 * @param array $wp_environments The list of environment types. Possible values 172 * include 'development', 'stage', 'production'. 160 173 */ 161 $ approved_environments = apply_filters( 'wp_approved_environment_types', $approved_environments );174 $wp_environments = apply_filters( 'wp_environment_types', $wp_environments ); 162 175 163 176 $current_env = ''; 164 177 165 // Check if a environment variable has been set for max flexibility, if `getenv` is available on the system.178 // Check if the environment variable has been set, if `getenv` is available on the system. 166 179 if ( function_exists( 'getenv' ) ) { 167 180 $has_env = getenv( 'WP_ENVIRONMENT_TYPE' ); 168 181 if ( false !== $has_env ) { … … 190 203 $current_env = apply_filters( 'wp_get_environment_type', $current_env ); 191 204 192 205 // Make sure the environment is an allowed one, and not accidentally set to an invalid value. 193 if ( ! in_array( $current_env, $ approved_environments, true ) ) {206 if ( ! in_array( $current_env, $wp_environments, true ) ) { 194 207 $current_env = 'production'; 195 208 } 196 209