@@ -26,12 +26,11 @@ trait IOHelperTrait
2626 public $ tmp = [];
2727
2828 /**
29- * @param bool $skip_create_path
30- * @param $config
29+ * @param bool $readonly
3130 * @return string
3231 * @throws phpFastCacheIOException
3332 */
34- public function getPath ($ getBasePath = false )
33+ public function getPath ($ readonly = false )
3534 {
3635 $ tmp_dir = rtrim (ini_get ('upload_tmp_dir ' ) ? ini_get ('upload_tmp_dir ' ) : sys_get_temp_dir (), '\\/ ' ) . DIRECTORY_SEPARATOR . 'phpfastcache ' ;
3736
@@ -51,10 +50,6 @@ public function getPath($getBasePath = false)
5150 $ path = $ this ->config [ 'path ' ];
5251 }
5352
54- if ($ getBasePath === true ) {
55- return $ path ;
56- }
57-
5853 $ securityKey = array_key_exists ('securityKey ' , $ this ->config ) ? $ this ->config [ 'securityKey ' ] : '' ;
5954 if (!$ securityKey || $ securityKey === 'auto ' ) {
6055 if (isset ($ _SERVER [ 'HTTP_HOST ' ])) {
@@ -71,28 +66,31 @@ public function getPath($getBasePath = false)
7166 $ securityKey = static ::cleanFileName ($ securityKey );
7267
7368 $ full_path = rtrim ($ path , '/ ' ) . '/ ' . $ securityKey ;
74- $ full_pathx = md5 ( $ full_path) ;
69+ $ full_pathx = $ full_path ;
7570
71+ if ($ readonly === true ) {
72+ return $ full_path ;
73+ }
7674
7775 if (!isset ($ this ->tmp [ $ full_pathx ]) || (!@file_exists ($ full_path ) || !@is_writable ($ full_path ))) {
7876 if (!@file_exists ($ full_path )) {
7977 @mkdir ($ full_path , $ this ->setChmodAuto (), true );
80- }
81- if (!@is_writable ($ full_path )) {
78+ }else if (!@is_writable ($ full_path )) {
8279 @chmod ($ full_path , $ this ->setChmodAuto ());
8380 }
84- if (!@is_writable ($ full_path )) {
85- // switch back to tmp dir again if the path is not writeable
81+
82+ if ($ this ->config [ 'autoTmpFallback ' ] && !@is_writable ($ full_path )) {
83+ /**
84+ * Switch back to tmp dir
85+ * again if the path is not writable
86+ */
8687 $ full_path = rtrim ($ tmp_dir , '/ ' ) . '/ ' . $ securityKey ;
8788 if (!@file_exists ($ full_path )) {
8889 @mkdir ($ full_path , $ this ->setChmodAuto (), true );
8990 }
90- if (!@is_writable ($ full_path )) {
91- @chmod ($ full_path , $ this ->setChmodAuto ());
92- }
9391 }
9492 if (!@file_exists ($ full_path ) || !@is_writable ($ full_path )) {
95- throw new phpFastCacheIOException ('PLEASE CREATE OR CHMOD ' . $ full_path . ' - 0777 OR ANY WRITABLE PERMISSION! ' , 92 );
93+ throw new phpFastCacheIOException ('PLEASE CREATE OR CHMOD ' . $ full_path . ' - 0777 OR ANY WRITABLE PERMISSION! ' );
9694 }
9795
9896 $ this ->tmp [ $ full_pathx ] = true ;
0 commit comments