From 83af1505cabe631582a1f29466052ee4a7bd9747 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 29 Nov 2022 16:12:14 +1300 Subject: [PATCH] Do not set cache in cache-bypass mode --- ext/afform/core/CRM/Afform/AfformScanner.php | 23 ++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/ext/afform/core/CRM/Afform/AfformScanner.php b/ext/afform/core/CRM/Afform/AfformScanner.php index 8d02738fe7..b7f3a5a47c 100644 --- a/ext/afform/core/CRM/Afform/AfformScanner.php +++ b/ext/afform/core/CRM/Afform/AfformScanner.php @@ -36,9 +36,8 @@ class CRM_Afform_AfformScanner { * @return array * Ex: ['view-individual' => ['/var/www/foo/afform/view-individual']] */ - public function findFilePaths() { - if (!CRM_Core_Config::singleton()->debug) { - // FIXME: Use a separate setting. Maybe use the asset-builder cache setting? + public function findFilePaths(): array { + if ($this->isUseCachedPaths()) { $paths = $this->cache->get('afformAllPaths'); if ($paths !== NULL) { return $paths; @@ -61,10 +60,26 @@ class CRM_Afform_AfformScanner { $this->appendFilePaths($paths, $this->getSiteLocalPath(), ''); - $this->cache->set('afformAllPaths', $paths); + if ($this->isUseCachedPaths()) { + $this->cache->set('afformAllPaths', $paths); + } return $paths; } + /** + * Is the cache to be used. + * + * Skipping the cache helps developers moving files around & messes with developers + * debugging performance. It's a cruel world. + * + * FIXME: Use a separate setting. Maybe use the asset-builder cache setting? + * + * @return bool + */ + private function isUseCachedPaths(): bool { + return !CRM_Core_Config::singleton()->debug; + } + /** * Get the full path to the given file. * -- 2.25.1