summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2024-04-13 00:39:37 +0300
committerAndrew Dolgov <[email protected]>2024-04-13 00:39:37 +0300
commitae5e7568f59b9ecbefe0c86ffc7d314fd78d114c (patch)
treee09d736831899bc9480ef31d9a20d12d4a23f091
parent435c321caaf3ae7aca936f175348d9efb40d6419 (diff)
force-set absolute path for local cache if CACHE_DIR config value is relative
-rw-r--r--classes/Cache_Local.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/classes/Cache_Local.php b/classes/Cache_Local.php
index 8ac634a3e..dd3548111 100644
--- a/classes/Cache_Local.php
+++ b/classes/Cache_Local.php
@@ -11,7 +11,14 @@ class Cache_Local implements Cache_Adapter {
}
public function set_dir(string $dir) : void {
- $this->dir = Config::get(Config::CACHE_DIR) . "/" . basename(clean($dir));
+ $cache_dir = Config::get(Config::CACHE_DIR);
+
+ // use absolute path local to current dir if CACHE_DIR is relative
+ // TODO: maybe add a special method to Config() for this?
+ if ($cache_dir[0] != '/')
+ $cache_dir = dirname(__DIR__) . "/$cache_dir";
+
+ $this->dir = $cache_dir . "/" . basename(clean($dir));
$this->make_dir();
}