mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
make cache_buster method more stable with windows environments and prevent error logs of files missing on purpose
This commit is contained in:
@@ -37,11 +37,20 @@ class Paths
|
||||
// make sure $filepath starts with a slash
|
||||
if (substr($filepath, 0, 1) !== '/') $filepath = '/' . $filepath;
|
||||
|
||||
$fullpath = $_SERVER['DOCUMENT_ROOT'] . $filepath;
|
||||
// These files are not existent on purpose and should not trigger error logs
|
||||
$err_exceptions = [
|
||||
'/assets/json/datatables_languages/en-US.json',
|
||||
];
|
||||
|
||||
// Use DIRECTORY_SEPARATOR for cross-platform compatibility (aka Windows may needs special handling)
|
||||
$fullpath = rtrim($_SERVER['DOCUMENT_ROOT'], '/\\') . str_replace('/', DIRECTORY_SEPARATOR, $filepath);
|
||||
|
||||
if (file_exists($fullpath)) {
|
||||
return base_url($filepath) . '?v=' . filemtime($fullpath);
|
||||
} else {
|
||||
log_message('error', 'CACHE BUSTER: File does not exist: ' . $fullpath);
|
||||
if (!in_array($filepath, $err_exceptions)) {
|
||||
log_message('error', 'CACHE BUSTER: File does not exist: ' . $fullpath);
|
||||
}
|
||||
}
|
||||
return base_url($filepath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user