diff --git a/VERSIONS_HOTLINE/197682 b/VERSIONS_HOTLINE/197682 new file mode 100644 index 0000000000000000000000000000000000000000..8af719ef0a5ee522e0bc93d5f7cd714035c59545 --- /dev/null +++ b/VERSIONS_HOTLINE/197682 @@ -0,0 +1 @@ + - correctif #197682 : Administration : correction du sytème de mise en cache de l'explorateur de fichiers qui empéchait la création de dossier. \ No newline at end of file diff --git a/library/Class/FileManager/FileSystem.php b/library/Class/FileManager/FileSystem.php index eedeb86eb71dd4e5616b5278a99e1623b31d2acb..51de1853c87f3398e5a3e0ffcf1da2e2ca8ec2cc 100644 --- a/library/Class/FileManager/FileSystem.php +++ b/library/Class/FileManager/FileSystem.php @@ -243,8 +243,9 @@ class Class_FileManager_FileSystem { public function clearCache() { $cache = new Storm_Cache; - foreach($this->_cached_paths as $path) - $cache->remove($path); + + foreach($this->_cached_paths as $key =>$path) + $cache->remove($key); return true; } @@ -347,7 +348,7 @@ class Class_FileManager_FileSystem { protected function _glob($path, $cache = true) { - $this->_cached_paths[] = $path; + $this->_cached_paths[json_encode($path)] = 1; $closure = function() use ($path) { @@ -372,7 +373,6 @@ class Class_FileManager_FileSystem { sort($paths, SORT_NATURAL); return $paths; }; - if($cache) return (new Storm_Cache()) ->memoize(json_encode($path), $closure); @@ -384,8 +384,8 @@ class Class_FileManager_FileSystem { public function search($term, $path) { if(!$term) return []; - - $this->_cached_paths[] = $term . $path; + $cache_key = json_encode([$term . $path]); + $this->_cached_paths[$cache_key] = 1; $closure = function() use ($term, $path) { $cmd = sprintf('find %s -iname "*%s*"', @@ -407,8 +407,9 @@ class Class_FileManager_FileSystem { return array_filter(array_map([Class_FileManager::class, 'find'], $found)); }; + return (new Storm_Cache()) - ->memoize(json_encode([$term . $path]), $closure); + ->memoize( $cache_key, $closure); } diff --git a/tests/library/Class/FileManager/FileSystemTest.php b/tests/library/Class/FileManager/FileSystemTest.php index ed6c831bd569dc36de56213dae192b3c3cb1fa19..234fa9fd2d14a4872dd7c6f7719d82d57d471f18 100644 --- a/tests/library/Class/FileManager/FileSystemTest.php +++ b/tests/library/Class/FileManager/FileSystemTest.php @@ -35,3 +35,27 @@ class Class_FileManager_FileSystemTest extends ModelTestCase { parent::tearDown(); } } + + + + +class FileSystemCacheTest extends AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + Storm_Cache::beVolatile(); + Class_FileManager::beOpenBar(); + } + + + /** @test */ + public function pageShouldContainsFichiersDirectory() { + $this->dispatch('/admin/file-manager/index'); + $this->assertFalse( (new \Storm_Cache)->load(json_encode("userfiles"))); + } + + + public function tearDown() { + Class_FileManager::reset(); + parent::tearDown(); + } +}