mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
fix: RateLimit graceful degradation on permission denied
Silence mkdir() with @ operator; guard file_put_contents with is_writable() check. When storage/cache/rate_limit is not writable by php-fpm, requests are allowed through instead of throwing warnings that flood the nginx error log.
This commit is contained in:
@@ -22,7 +22,7 @@ class RateLimit {
|
||||
|
||||
// Create cache directory if it doesn't exist
|
||||
if (!is_dir($this->cacheDir)) {
|
||||
mkdir($this->cacheDir, 0755, true);
|
||||
@mkdir($this->cacheDir, 0755, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,8 +79,10 @@ class RateLimit {
|
||||
// Add new request timestamp
|
||||
$data[] = $now;
|
||||
|
||||
// Save updated data
|
||||
file_put_contents($file, json_encode($data));
|
||||
// Save updated data (silently skip if directory is not writable)
|
||||
if (is_dir($this->cacheDir) && is_writable($this->cacheDir)) {
|
||||
file_put_contents($file, json_encode($data));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user