So in an addon I'm working on at the moment I have stumbled across an issue with the connector.php files which affects all addons with CMP's as far as I can see.
Basically in each connector we first have a call to require the config.inc.php file at the root of our MODX install to give us the core path from the defined constant MODX_CORE_PATH, fair enough.
The problem as I see it is that we then go on to require the controller index php file which itself calls in the config.inc.php file in the connectors directory (with the same defined constants as those in the config.inc.php file in our MODX install root) and this means that we are attempting to define the same constants again, namely MODX_CORE_PATH and MODX_CONFIG_KEY. This raises an error in PHP as you can not redefine constants. The fact that we called in our original config.inc.php file with a require_once doesn't help because the second call to config.inc.php in the controller index file is calling the config.inc.php file in the controllers directory - i.e. a different file to the one in our install rooot called in from our connector.php file.
A simple solution to this that wouldn't break existing addons would be to update the config.inc.php file in the controllers directory so that it changes from:
define('MODX_CORE_PATH', '/home/mppiintc/public_html/rrc/core/');
define('MODX_CONFIG_KEY', 'config');
to:
if(!defined('MODX_CORE_PATH')){
define('MODX_CORE_PATH', '/home/mppiintc/public_html/rrc/core/');
}
if(!defined('MODX_CONFIG_KEY')){
define('MODX_CONFIG_KEY', 'config');
}
Is there something I'm missing here?
[ed. note: freelancewebdev last edited this post 13 years, 10 months ago.]