Draft: Implement new loadConfig() and localConfigCached() methods#50
Draft: Implement new loadConfig() and localConfigCached() methods#50amulet1 wants to merge 1 commit intohorde:FRAMEWORK_6_0from
Conversation
|
@TDannhauer Please review. |
|
I like the idea very much! However: @amulet1 Can you make it an injectable / autowirable class object rather than a static? Better for unit testing / mocking |
|
Note, Is this still a problem for unit testing? |
|
Critical bug on line 1865: Fix by using // Load global configuration file.
if (defined('HORDE_CONFIG_BASE')) {
$conf_dir = HORDE_CONFIG_BASE . DIRECTORY_SEPARATOR . $app . DIRECTORY_SEPARATOR;
} else {
if ($app == 'horde' && defined('HORDE_BASE')) {
$conf_dir = HORDE_BASE . '/config/';
} else {
$conf_dir = $GLOBALS['registry']->get('fileroot', $app) . '/config/';
}
}Alternative: Make |
|
This is an unmerged/untested draft. And even if merged, it is not going to be used anywhere. I will fix. |
|
Things to discuss/agree on:
|
|
Waiting for the feedback... |
|
I don't get the big picture here. Why new registry methods when it already does too much and needs a wholesale refactor? I think I just need to understand what you want to achieve here. In the bigger picture, registry should only be concerned with application paths and maybe the inter-app API. Anything else needs to be separated, especially config loading, authentication, permission checking, locale initialization, backend logins (imap!), notification system setup. If we have an urgent need to change backend loading, let's consider. |
This is because the original intention was to replace
(1) I will add capturing/discarding output (with a warning). It was not clear why the output was captured (but never used) in the original implementation.
See #49.
There is no urgent need, just an idea to finally get rid of old code and consolidate config loading to use a simpler call. The modernization could be done later. (2) I will move it to a separate class (with its own cache). The existing code could still called it via the registry method stub (I prefer not to use globals). Would it be okay with (1) and (2) implemented? |
|
So, I guess we do not want to rely on this after all, given the #65 (was AI used there?). While #65 looks modern (but not fully complete) it does not help to achieve any of the goals that were not achievable (or achieved) already. While this sounds a little more conservative, I would prefer that we focus on fixing what is broken, on consolidating existing various similar implementations into optimized versions, migrating to already existing (but still unused modernized code). This all will help to produce stable releases (finally!). Among our important goals I see that we want to improve stability, not break anything existing without a good reason and provide sufficient backward compatibility. This would help to avoid breakage due to potentially overlooked things, and increase overall stability. And if adding modern stuff helps with that, but all means let us do it). |
|
Hi, I think we are not so far apart. I don't see how the new API affects stability as it does not touch any existing system. The problem with trying to "fix" the old bootstrap process with lib/core.php (not a class), reliance on Horde_Autoloader, unexpected require_once in relative paths and recurring double definition of classes is we tried that since 2022 and it's leading nowhere. So I'd rather build a new API without the Horde 3/Horde 4 constraints we no longer have and use it on some peripheral features, hammer out any bugs and issues, evolve it and when there is enough confidence, increase exposure. I see your tremendous work in ActiveSync and Forms and it's really hard to both make these old interfaces work with new PHP versions, new features and use cases but also not break anything. It's impressive how rarely anything breaks in this process. I want to make sure we eventually have an easier life so I am gradually sifting through my non-public work from the maintaina era when collaborating with other colleagues on non-groupware use cases of the framework. It's not like what you see recently pops up out of nowhere. I also tried to incorporate some of your ideas but not the caching right now. It's something we are going to want, I see it. We want to cache/compile the routes and also the registry config to reduce the complexity we carry with each request. We have little room in the old registry framework - everything relies on everything, there's globals and undocumented expectations everywhere. I have been throwing out pieces from core.php for years and it always came with some breakage and guessing. It's so tiresome I'd rather leave it mostly untouched until we no longer need it at all. But if this new loader method helps bridge the gap between current core and a future core, let's do it. |
DRAFT
Proposed initial code changes based on #49:
loadConfig()andloadConfigCached()both using internal staticloadConfigInternal()method.$vars = null, then all loaded variables are returned. This is mostly useful for caching (but we may not even need it - see below).$load_vars) that isolates loaded variables from all other variables, and therefore we only capture what is really loaded. Beforecompactwas used to retrieve only the variables we are after, but the new code allows to retrieve (and possible cache) all the loaded variables.Typical usage:
Instead of
$backends = $registry-> Horde::loadConfiguration('backends.php', 'backends', 'gollem');:$backends = $registry->loadConfig('backends.php', 'backends');Another example:
becomes