From 9c14abfe4a94c03c6b4df26fb0e3d1c4350293bd Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Wed, 13 Jan 2016 13:44:46 +0100 Subject: handle empty filelist, handle scripts with query-args --- itjs.class | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/itjs.class b/itjs.class index 2be3842..715247c 100644 --- a/itjs.class +++ b/itjs.class @@ -133,7 +133,7 @@ static function filenames($filelist) foreach (it::match("[-\w.=?&]+", basename($filelist), array('all' => true)) as $file) # split by comma but ignore illegal chars { - $filenames = $special[$file] ?: (file_exists("$local/$file") ? "$local/$file" : "$libsearch/itjs/$file"); + $filenames = $special[$file] ?: (file_exists("$local/" . it::match('[^?]*', $file)) ? "$local/$file" : "$libsearch/itjs/$file"); foreach (explode(",", $filenames) as $filename) if (!$seen[$filename]++ && file_exists($filename)) @@ -194,6 +194,7 @@ static function checksum($fnlist, $p = array()) { $p += array('short_expire' => true); + $filenames = array(); foreach (is_array($fnlist) ? $fnlist : itjs::filenames($fnlist) as $filename) $filenames[] = !file_exists($filename) && file_exists($t = it::replace(array('^/www/[^/]*' => "/www/lib.search.ch"), $filename)) ? $t : $filename; @@ -202,9 +203,9 @@ static function checksum($fnlist, $p = array()) $key = "itjs_" . md5(join("", it::map('"$v" . @filemtime("$v")', $filenames))); - if ($p['short_expire'] && (time() - max(@array_map('filemtime', $filenames)) < 60)) + if ($filenames && $p['short_expire'] && (time() - max(@array_map('filemtime', $filenames)) < 60)) return "-"; # trigger short expire, our file may not yet be up to date on other slaves - else + else if ($filenames) return it_cache::get($key) ?: it_cache::put($key, substr(md5(self::filecontents($filenames, false)), 0, 10), array('ttl' => 60)); } -- cgit v1.2.3