Commit 4e971737 authored by totten's avatar totten
Browse files

AfformScanner - Simplify cache. Fix CLI/web sync bug.

Example bug:

1. Find a packaged (non-overriden) form - e.g. `mockPage`
2. Run `cv api4 Afform.update +w name=mockPage +v permissions='*always allow*'
3. Run `curl http://localhost/civicrm/mock-page`
4. Observe: the page-load fails even though the permissions say it should work

The call to `Afform.update` should trigger a cache-clear, but it only fixes
on the CLI...  because the CLI and web have different runtime IDs.

The runtime-id was included preventively in anticipation that oddball
multisite arrangements might need to store these things separately.  But I
think it's overdone, because the runtime-ID factors in things like
`SCRIPT_FILENAME` which has no bearing on the whether to use the same cache.

Let's KISS and *if* there's any kind of multisite issue, then we can revisit.
parent 119bd37e
......@@ -29,7 +29,10 @@ class CRM_Afform_AfformScanner {
public function __construct() {
// TODO Manage this is a service, and inject the cache service.
$this->cache = new CRM_Utils_Cache_SqlGroup([
'group' => md5('afform_' . CRM_Core_Config_Runtime::getId() . $this->getSiteLocalPath()),
// Note: If there are edge-case bugs with multisite, consider changing
// the group key - but tread carefully to ensure that (eg) CLI+web workers
// see the same cache.
'group' => 'afform_scanner',
'prefetch' => FALSE,
]);
// $this->cache = new CRM_Utils_Cache_Arraycache([]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment