getkirby-v2 / toolkit

This is the deprecated toolkit for Kirby v2.
http://getkirby.com
81 stars 50 forks source link

Multi-environment config files and overwrite problem #253

Closed olach closed 7 years ago

olach commented 7 years ago

From the forum post.

Normally, when using multi-environment setup we can have a regular config.php file and a local config.localhost.php file that can overwrite settings for your local dev setup.

This way of overwrite some config values works fine, until you have this code in your config.php:

if (!site()->user()):
    // Deactivate cache settings etc...
endif;

If the function site()->user() is being run in the config.php, every config setting that is specified afterwards, cannot be overwritten in another local config file like config.localhost.php.

The site()->user() is often used to disable the cache if a user is logged in. A quick workaround for this problem is to place this code at the very last end of the config.php file. But the root cause for this should be addressed.

lukasbestle commented 7 years ago

The issue was that site()->user() creates a Site object earlier than expected. Creating a site object loads the configuration. And that's why the custom file is loaded in this stage. Options defined in this custom file are then overwritten again by the stuff that follows after the call to the Site object.

I have fixed this on the develop branch.