Plugin config params in config.php throw a strict standards notice: "Creating default obect from empty value"
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mahara |
Fix Released
|
Medium
|
Aaron Wells |
Bug Description
In bug 1196781, Mahara 1.9, we added the ability to set plugin configuration parameters in config.php. The syntax I suggested for this is a chain of nested objects, e.g:
$cfg->
However this throws a PHP strict standards notice, e.g. "Creating default object from empty value in config.php on line 90". And in PHP 5.4, which more and more people are using, strict standards notices are included in E_ALL, which is the default for many servers. Resultantly, any users who are using plugin config params in config.php are likely to get this notice clogging up their logs. We disable E_STRICT notices in error.php, but config.php is loaded and evaluated before error.php
You can of course manually initialize each object in the chain, but that's not very concise.
$cfg->plugin = new stdClass();
$cfg->
$cfg->
$cfg->
And it's a bit awkward for our deployment process, which previously was able to store the configs in a database as a set of (key, value) pairs and then just churn those into PHP statements of the sort "\$cfg->{$key} = {$value};". If we needed to initialize each object as well, that would be a lot trickier.
So the current workaround we're using is just to put an @ before it:
@$cfg-
Anyway, after giving this some thought, I think the best way to go is to replace the "->"'s with underscores _. So this becomes:
$cfg->plugin_
This has these ramifications:
1. After loading up config.php we'll need to locate all the configs that start with "plugin_" and parse them into proper plugin configs.
2. The parsing will follow this regular expression: \^plugin_
3. Core config parameters are consequently forbidden from beginning with "plugin_".
Changed in mahara: | |
status: | Fix Committed → Fix Released |
Patch for "master" branch: https:/ /reviews. mahara. org/3419