pimcore / pimcore

Core Framework for the Open Source Data & Experience Management Platform (PIM, MDM, CDP, DAM, DXP/CMS & Digital Commerce)
http://www.pimcore.com
Other
3.38k stars 1.43k forks source link

Setting PIMCORE_ENVIRONMENT in dotenv file not working anymore #4703

Closed bramstroker closed 5 years ago

bramstroker commented 5 years ago

Bug Report

Expected behavior

Pimcore is run in with the environment I define is my DotEnv file

Actual behavior

Pimcore environment is set to prod

Steps to reproduce

Add the following to .env file in pimcore root folder:

PIMCORE_ENVIRONMENT=dev

Add a breakpoint to line after prepareEnvVariables call in Bootstrap.php and inspect $_ENV contents. PIMCORE_ENVIRONMENT should be dev but is prod.

This is an issue with Pimcore 6.0.4. In pimcore 6.0.1 everything was working as expected.

Possible cause of issue.

In one of the latest commits $_ENV['PIMCORE_ENVIRONMENT'] is set hard in the code before $dotEnv->loadEnv() is called. DotEnv by default does NOT override existing environment variables, so there is no way to override it with the dot env file anymore.

brusch commented 5 years ago

@bramstroker thanks for reporting! Can you please test this patch: https://github.com/pimcore/pimcore/commit/f0abc8c5ca78216d1caf228adac337b6dbc9617a.patch ?

Thanks for a quick feedback!

bramstroker commented 5 years ago

@brusch Yes this patch is working correctly for me. Thanks for the quick resolution!

rajesh17692 commented 3 years ago

Hello Can anyone guide me on how the patch can be installed

NiklasBr commented 3 years ago

@rajesh17692 While waiting for the patch to be implemented into Pimcore, you can install Composer Patches and then follow the instructions for External patches (or download it and use the instructions for internal).