Record Access is not being updated when a new record is added
Description
Environment
Activity
Carlos Ruiz January 16, 2024 at 12:52 PM
Hi @Heng Sin Low
Could you please take a look to the pull request 2194 ?
Comments:
MRecordAccess.afterDelete is necessary, @Diego Ruiz missed it on the previous commit
the change on CacheMgt.resetLocalCache() is also necessary because reset() is not being called when the CacheListener is empty, but the method resetLocalCache(String, int) has it correct (not checking if is empty)
this implementation of MRole.CCacheListener looks correct, the reset methods there are being called, but is not working because the Env.getCtx() there is not getting the ServerContext, but a context that is almost empty, it just have #AD_Language and some CLog* entries. How can we access the ServerContext in this instance?
Regards,
Carlos Ruiz
Carlos Ruiz January 14, 2024 at 1:39 PM
Just checked, the reason why cache reset doesn’t work in zk is because the default role is not being retrieved from cache, but from context.
See MRole:127
@Heng Sin Low - I tried to solve this implementing a CCacheListener on MRole, but failed
The idea is simple:
in MRole.setDefaultRole, set a cache listener on that default role
the cache listener must simply call MRole.getDefault(ctx, reload=true) on reset() and reset(int) when the role being reset is the default role
Can you please check? Something didn’t work for me in that approach, if that works, then we can add the same cache listener on all tables that are loaded in arrays in role, like all the AD_*Access tables
Diego Ruiz January 12, 2024 at 1:29 PM
The pull request solves the issue on the REST layer. I do not understand why resetting cache does not work on ZK, but you still need to re-login for record access to be updated.
When you add a new Record Access restriction, it is not immediately loaded or usable because MRole uses a Cached version of the array. This creates a problem when querying REST data because for restrictions to take effect, you need to restart the server or log out and log back in.
In ZK, you need to re-login as well to take effect. Running cache reset does not work.