Jump to content

Weird happenings with $config


MarkE
 Share

Recommended Posts

I've recently upgraded to v3.0.165 from 3.0.153 and it seem that the $config API is not working in the same way. Has anything changed. Two examples:

1. Use of $config to pass settings across a multi-site, multi-instance environment stopped working. I fixed this by changing to use setting() - see 

 

2. Use of $config to determine environment. I set $config->BH_ENV = 'LIVE'; in config.php and overwrite it later in that file with $config->BH_ENV = 'DEV';  as follows:

if(strpos($config->paths->root, 'M:/laragon/') === 0) {
    $config->BH_ENV = 'DEV';
//......
}

However, in some circumstances $config->BH_ENV seems to take the value 'DEV' in the live environment. As far as I am aware, the relevant code has not changed - just the PW version. I have triple checked and there is nowhere other than the two assignaments decribed above where $config->BH_ENV is set. At the moment I am having to do a work-round by using different code in the two environments, but that's not a good solution. (BTW setting() doesn't seem to be available in config.php).

Link to comment
Share on other sites

33 minutes ago, MarkE said:

(BTW setting() doesn't seem to be available in config.php)

So definitely it cannot be available in $config, because $"config is parsed before the engine gets started".  
Way before init is running and much way before ready! And most of the functionality only is available after (the engine is) ready?

Link to comment
Share on other sites

25 minutes ago, horst said:

Way before init is running

Yeah - I was able to fix issue 1 because it is set in init. I guess I could try doing the environment test in init and setting a setting() there, but I thought it would be best to set $config->BH_ENV as early as possible and, besides, I would like to understand better what is happening with $config. Other assignments which are environment-dependent are set in the same config.php script - e.g. $config->httpHosts - and I am concerned that these may be affected also (willl do some investigations). 

More generally, are there any thoughts on when best to use $config and when to use setting()?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...