It is not a bug, but a serious issue.
In version previous to 1.7 it was possible to overwrite values of configuration values in plugins on the fly, i.e.
$plugin_cf['plugin_name'].['value']=$new_value
was executed and the plugin configuration changed to a new value. This functionality could be used to change plugins default configuration to alternate behaviour. I used this possibility in many of mine plugins, among other in PHP Viewer where some documents needs to be refreshed frequently (eg sports results) and other never change. in order to satisfy both needs it's necessary to change plugins configuration on some pages, or even the same page displaying to different pdf documents.
The possibility to manipulate configuration variables seems to be gone in CMSimple_XH version 1.7. and I get the warning: "Indirect modification of overloaded element of XH\PluginConfig has no effect", and it really has no effect. Of course it can be solved by passing all configurations values to plugin function but it's against the idea of having configurations variables. Any suggestion how to manipulate plugins configuration variables in version 1.7?
How to manipulate plugin configuration variables ($plugin_cf)
-
- Posts: 155
- Joined: Thu Oct 06, 2011 7:00 am
Re: How to manipulate plugin configuration variables ($plugin_cf)
IMO it is correct to generally protect the plugin configuration. Otherwise you could overwrite config values of plugins other than yours.
If you want to modify configuration values you better copy them to your own local configuration set in your environment. and use it from there.
If you want to modify configuration values you better copy them to your own local configuration set in your environment. and use it from there.
Re: How to manipulate plugin configuration variables ($plugin_cf)
This change has been introduced by implementing Lazy loading of plugin config and language files. Preventing write access to $plugin_cf|tx was not the reason for the implementation, but rather a side-effect. I guess even that could be fixed (would probably require references), but I agree with manu that it's better not to change any configuration or language settings from a plugin, but to leave all manipulation to the core.simpleSolutions.dk wrote:The possibility to manipulate configuration variables seems to be gone in CMSimple_XH version 1.7. and I get the warning: "Indirect modification of overloaded element of XH\PluginConfig has no effect", and it really has no effect.
Instead of manipulation configuration variables, what about using an own global variable, if necessary? For instance:simpleSolutions.dk wrote:Of course it can be solved by passing all configurations values to plugin function but it's against the idea of having configurations variables. Any suggestion how to manipulate plugins configuration variables in version 1.7?
Code: Select all
function my_plugin($a_setting = null)
{
global $my_plugin_setting, $plugin_cf;
$my_plugin_setting = isset($a_setting) ? $a_setting : $plugin_cf['my_plugin']['a_setting'];
// actual code using $my_plugin_setting instead of $plugin_cf['my_plugin']['a_setting']
}
Christoph M. Becker – Plugins for CMSimple_XH