Skip to content

Commit 404eebc

Browse files
committed
check file existence and availability of writable
1 parent eca7290 commit 404eebc

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/phpFastCache/Core/PathSeekerTrait.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function getPath($readonly = false)
8282
if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) {
8383
if (!@file_exists($full_path)) {
8484
@mkdir($full_path, $this->setChmodAuto(), true);
85-
} elseif (!@is_writable($full_path)) {
85+
}elseif (!@is_writable($full_path)) {
8686
if (!@chmod($full_path, $this->setChmodAuto()))
8787
{
8888
/**
@@ -91,14 +91,19 @@ public function getPath($readonly = false)
9191
*/
9292
$full_path = $full_path_tmp;
9393
if (!@file_exists($full_path)) {
94-
if (!@mkdir($full_path, $this->setChmodAuto(), true))
95-
{
96-
throw new phpFastCacheDriverException('PLEASE CREATE OR CHMOD ' . $full_path . ' - 0777 OR ANY WRITABLE PERMISSION!');
97-
}
94+
@mkdir($full_path, $this->setChmodAuto(), true);
9895
}
9996
}
10097
}
10198

99+
/**
100+
* In case there is no directory
101+
* writable including tye temporary
102+
* one, we must throw an exception
103+
*/
104+
if (!@file_exists($full_path) || !@is_writable($full_path)) {
105+
throw new phpFastCacheDriverException('PLEASE CREATE OR CHMOD ' . $full_path . ' - 0777 OR ANY WRITABLE PERMISSION!');
106+
}
102107
$this->tmp[ $full_path_hash ] = $full_path;
103108
$this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false);
104109
}

0 commit comments

Comments
 (0)