Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

## 2.0.1 under development

- no changes in this release.
- Bug #47: Set permissions for new directory via `chmod()` (@dehbka)

## 2.0.0 July 21, 2022

- Chg #44: Raise the minimum `psr/simple-cache` version to `^2.0|^3.0` and the minimum PHP version to `^8.0` (@dehbka)

## 1.0.1 March 23, 2021

- Chg: Adjust config for new config plugin (samdark)
- Chg: Adjust config for new config plugin (@samdark)

## 1.0.0 February 02, 2021

Expand Down
12 changes: 11 additions & 1 deletion src/FileCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,17 @@ private function normalizeTtl(null|int|string|DateInterval $ttl = null): ?int
*/
private function createDirectoryIfNotExists(string $path): bool
{
return is_dir($path) || (!is_file($path) && mkdir($path, $this->directoryMode, true) && is_dir($path));
if (is_dir($path)) {
return true;
}

$result = !is_file($path) && mkdir(directory: $path, recursive: true) && is_dir($path);

if ($result) {
chmod($path, $this->directoryMode);
}

return $result;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/FileCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ public function testDirMode(): void
}

$cache = new FileCache($this->tmpDir);
$newCache = $cache->withDirectoryMode(0755);
$newCache = $cache->withDirectoryMode(0777);

$this->assertInstanceOf(FileCache::class, $newCache);
$this->assertNotSame($cache, $newCache);
Expand All @@ -451,7 +451,7 @@ public function testDirMode(): void
$cacheFile = $this->invokeMethod($newCache, 'getCacheFile', ['a']);
$permissions = substr(sprintf('%o', fileperms(dirname($cacheFile))), -4);

$this->assertEquals('0755', $permissions);
$this->assertEquals('0777', $permissions);
}

public function testDirectoryLevel(): void
Expand Down