Refactor configuration handling: implement dynamic loading of config and cache paths for improved security and flexibility in Docker environments
This commit is contained in:
1 parent
c7b836bcf2
commit
bb65ecd43c
7 files changed
+53
-12
No files matched your search
@@ -20,7 +20,11 @@ function fritz_google_reviews(): array {
|
||||
return $fallback;
|
||||
}
|
||||
|
||||
$cacheFile = __DIR__ . '/../cache/google-reviews.json';
|
||||
// In Docker, FITZ_CACHE_DIR points into the writable data/ mount, outside
|
||||
// the web root, so deploys don't wipe it and www/ can stay read-only to
|
||||
// www-data. Local dev falls back to cache/ in the project root.
|
||||
$cacheDir = getenv('FITZ_CACHE_DIR') ?: __DIR__ . '/../cache';
|
||||
$cacheFile = $cacheDir . '/google-reviews.json';
|
||||
|
||||
if (is_file($cacheFile)) {
|
||||
$cached = json_decode((string) file_get_contents($cacheFile), true);
|
||||
@@ -33,7 +37,6 @@ function fritz_google_reviews(): array {
|
||||
$fresh = fritz_fetch_google_reviews($fallback);
|
||||
$fresh['fetched_at'] = time();
|
||||
|
||||
$cacheDir = dirname($cacheFile);
|
||||
if (!is_dir($cacheDir)) {
|
||||
@mkdir($cacheDir, 0775, true);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user