-
Notifications
You must be signed in to change notification settings - Fork 16
Description
We have (A) Horde_Deprecated::loadConfiguration() which is still used in several places. Internally it is rewritten to call (B) Horde_Registry::loadConfigFile(), which caches and returns instance of (C) Horde_Registry_Loadconfig class. Also Horde_Registry_Loadconfig is called directly in a few places.
I see several issues:
- Why do we still use the supposedly deprecated loadConfiguration()?
- It is questionable that cache in
Horde_Registry::loadConfigFile()really helps with anything. If we indeed load same file multiple times in the same app during a single request, than maybe something is wrong with the app. Additionally, the result depends on the$varsparameter, however the cache key disregards this, and if a call is ever made for the same config file but with different$varsparameter, it will return the previously cached value (wrong!). - The main reason
Horde_Registry_Loadconfiginstance is returned is to be able to access itsoutputandconfigproperties. Its constructor uses$registryglobal, which could be avoided if it was implemented as a method inHorde_Registryclass. - I looked at all places where the 3 methods are used across all Horde applications. As far as I can see,
outputproperty (which holds captured output produced by loaded file) is never used. I am not sure if there are some 3rd party applications that somehow rely on it, but clearly there are simpler ways to capture output. Places that use (B) or (C) useconfigproperty value - which is what the deprecatedHorde_Deprecated::loadConfiguration()method already did.
In nearly all cases (when a single variable was used) the "deprecated" code looked like
(D) $result = Horde::loadConfiguration($config_file, $var_name, $app);
The equivalent newer code is
(E) $result = $registry->loadConfigFile($config_file, $var_name, $app)->config[$var_name];
Suggestions:
Let's create a new (non-static!) method Horde_Registry:loadConfig which would generally replicate (A) behavior, but without any extra classes or methods involved, and without output being captured.
We have to decide if caching is needed (probably not, or at least it should be optional). If we need it, then at least it should be done smarter - e.g. cache values in Redis, and auto-refresh if file(s) last-modified timestamp changes.
We then switch to using this method instead of (A), (B) and (C) and remove the unused old code.
With this suggestion a typical call equivalent to (D) or (E) would be like this:
(F) $result = $registry->loadConfig($config_file, $var_name, $app);
Overall (F) is cleaner and simpler to use.
Any thoughts?