Today, I realized that after cloning the LIVE site to STAGING, the following constants are no longer defined at the top of wp-config.php.
<?php /* BEGIN KINSTA DEVELOPMENT ENVIRONMENT - DO NOT MODIFY THIS CODE BLOCK */ ?>
<?php if ( !defined('KINSTA_DEV_ENV') ) { define('KINSTA_DEV_ENV', true); /* Kinsta development - don't remove this line */ } ?>
<?php if ( !defined('JETPACK_STAGING_MODE') ) { define('JETPACK_STAGING_MODE', true); /* Kinsta development - don't remove this line */ } ?>
<?php /* END KINSTA DEVELOPMENT ENVIRONMENT - DO NOT MODIFY THIS CODE BLOCK */ ?>
Our development processes rely heavily on these constants when we want to customize plugin behavior depending on the environment.
We do define ‘staging’ in wp-config.php with
.define(‘WP_ENVIRONMENT_TYPE’, ‘staging’ );
but this is done manually, and we need to wait until the cloning process is over. Cloning and DB search and replace take time, especially in larger sites.
Ideally, the newly created STAGING wp-config.php should already declare the environment type, so there is no gap in which STAGING is still considered as being “live”.
Is there a plan to get those constants back?
Is there a bulletproof way to detect a non-production environment during site cloning?
These constants should be there in wp-config on the staging site. There might be a code on the site preventing this process from completing or a bug in Mykinsta.
However, since this isn’t in regards to DevKinsta, I would advise opening a chat with our Support Team.
The other day I contacted Kinsta support, and they reassured me that Kinsta has removed this feature from the STAGING sync process because it was thought that the feature was not essential or beneficial anymore.
I apologize about any confusion that occurred. I understand that you are looking for a way to identify the environment type a site installation is in as your development process relies on knowing this information. This is still possible without having to manually declare the WP_ENVIRONMENT_TYPE constant.
As it turns out, our platform already sets the WP_ENVIRONMENT_TYPE constant. This replaces the older KINSTA_DEV_ENV variable. The WP_ENVIRONMENT_TYPE is set to the following values depending on the environment:
Live environment: production
Standard staging environment: staging
Premium staging environment: development
You should be able to use the WP_ENVIRONMENT_TYPE value in your development process to determine if the site is on a live, staging or premium staging environment without having to manually define the value in the wp-config.php file.
Please let us know if this helps answer your question, or if you do need any further assistance. We are always happy to help!