summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2026-02-10 13:49:46 +0100
committerChristian Schneider2026-02-10 13:49:46 +0100
commita65e5673081f99d70067b167a63ed8ef1552dd23 (patch)
tree881bd62b4aa2d0d15fbca9ab86ea4f47cc3a2330
parent5728fe01af19f2e9dcc593e3389f3543786e4655 (diff)
downloaditools-a65e5673081f99d70067b167a63ed8ef1552dd23.tar.gz
itools-a65e5673081f99d70067b167a63ed8ef1552dd23.tar.bz2
itools-a65e5673081f99d70067b167a63ed8ef1552dd23.zip
Change failure return value of get_cache with 'returnheaders' true from false to null to allow [, , ] = it_url::get_cache() without PHP 8.5 warning
-rw-r--r--it_url.class8
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);