diff options
| -rw-r--r-- | it_url.class | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/it_url.class b/it_url.class index 716eb24..602e754 100644 --- a/it_url.class +++ b/it_url.class @@ -605,7 +605,7 @@ static function get_cache_filename($p) * @param $p['returnheaders'] Return array($path, $headers) instead of simply $path * @param $p['postprocess'] UNSUPPORTED, use ::get_cache_contents * @param $p['lock'] prevent multiple requests to same url from different processes [true] - * @return Cache filename or false if fetch failed + * @return Cache file path or false if fetch failed OR if $p['returnhreaders'] then [$path, $headers, (bool)$isnewfile] or null on failure */ static function get_cache($p = array()) { @@ -728,7 +728,9 @@ static function get_cache($p = array()) it::log('debug', 'getcachelog', $p['id'], $p['url'], !$isnewfile ? "" : "fetched=" . mb_substr(is_string($data) ? $data : "(assoc)", 0, 400)); ### EDC('getcache', $success, $path); # too verbose - return $success ? ($p['returnheaders'] || $p['returncachemiss'] ? [$path, $headers, (bool)$isnewfile] : $path) : false; + return $p['returnheaders'] || $p['returncachemiss'] + ? ($success ? [$path, $headers, (bool)$isnewfile] : null) + : ($success ? $path : false); } /** @@ -739,7 +741,7 @@ static function get_cache($p = array()) */ static function get_cache_contents($p) { - [$fn, $dummy, $cachemiss] = self::get_cache($p + ['returncachemiss' => true]) ?: []; # FIXME 2026-02 CS Should we change get_cache to return null instead of false? + [$fn, $dummy, $cachemiss] = self::get_cache($p + ['returncachemiss' => true]); if ($fn) { $result = it::file_get_contents($fn); |