Open deJaya opened 8 months ago
Confirmed. Bumping it :)
Just to confirm, you're saying it does not clear the resource cache (or a different one), and this is all with the standard cache setups?
Just to confirm, you're saying it does not clear the resource cache (or a different one), and this is all with the standard cache setups?
I can just tell for myself, but I am running a default MODX 3.0.4. clientconfig.clear_cache
is set to Yes
. I render an example client config setting in the default template. When I change the value in client config and save it I would expect the cache to be cleared instantly. Instead the old values are still visible until I clear the cache either manually, or save a resource/chunk/snippet.
That's the experience I have as well. Standard cache setup.
There was some discussion here
Yes, this is clearly a bug...I would expect client config to clear the whole cache after save when this setting is enabled.
Running into this issue too. Possibly having something to do with https://github.com/modmore/ClientConfig/blob/master/core/components/clientconfig/processors/mgr/settings/save.class.php#L73
From the modx error log:
PHP warning: rmdir(/.../core/cache/resource/web/resources/): Directory not empty
PHP warning: rmdir(/.../core/cache/resource/web/): Directory not empty
Current workaround is to create a plugin on the ClientConfig_ConfigChange
event and manually clearing the resource folder.
Correct @verstratenbram - that's exactly the line that is supposed to wipe the resource cache clean and I'm not sure why it wouldn't. 😂
I've wondered if we need to change that to use the refresh()
instead:
$this->modx->getCacheManager()->refresh([
'resource' => [],
]);
Hi @Mark-H, that seems to resolve the issue. Don't understand why the original code doesn't work though.
I've looked a bit further into this issue.
The previous error messages Directory not empty
can be ignored. This was because we are using a custom resource cache handler which uses the .cache.gz
extension for cache files instead of the default .cache.php
. Because of that the files were not getting deleted for some modCacheManager
functions. We have resolved this issue by using the default extension instead.
There is still something odd happening though. Upon saving the client configuration and immediately reloading the front-end, the old values persist. Yet, when waiting for 2-3 seconds after saving and then reloading the front-end, the correct values appear.
Just to be clear, the resource cache does get cleared, but it gets filled with the old client config values if you refresh the front-end page fast enough.
Summary
ClientConfig's system setting
clientconfig.clear_cache
does not clear the cache when ClientConfig settings are savedStep to reproduce
Set
clientconfig.clear_cache
toYes
[default]Observed behavior
When saving a ClientConfig setting, the cache should be cleared [as I understand it] - but in all my tests, it's still necessary to manually clear the cache or call the setting uncached.
Expected behavior
MODX cache should be cleared
Environment
ClientConfig version 2.4.0-pl, MODX version 3.0.4-pl,
PHP version 8.2.