diff options
author | Urban Müller | 2023-03-23 16:43:54 +0100 |
---|---|---|
committer | Urban Müller | 2023-03-23 16:43:54 +0100 |
commit | 181342b8e9fd9106d3b1ab1fd0b808e299871766 (patch) | |
tree | 2bf03855fa035e0edcfd9d17c95ed45d8faba490 | |
parent | 539712a43c2568849bc119081f12606bc8029e3c (diff) | |
download | itools-181342b8e9fd9106d3b1ab1fd0b808e299871766.tar.gz itools-181342b8e9fd9106d3b1ab1fd0b808e299871766.tar.bz2 itools-181342b8e9fd9106d3b1ab1fd0b808e299871766.zip |
use json for new meta info storage; stil support serialized .php for a while
-rw-r--r-- | it_url.class | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/it_url.class b/it_url.class index 7bcf22d..ba194e7 100644 --- a/it_url.class +++ b/it_url.class @@ -581,7 +581,7 @@ static function get_cache_filename($p) * @param $p['it_error'] parameters for it::error(), false means ignore errors, anything else gets passed to it::error() if errors occur * @param $p['keepfailed'] keep old versions of files if download fails (sending alerts conservatively) * @param $p['returnheaders'] Return array($path, $headers) instead of simply $path - * @param $p['postprocess'] NOT SUPPORTED, use ::get_cache_contents + * @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 */ @@ -616,7 +616,7 @@ static function get_cache($p = array()) if ($data = $url->_get($p + ['checkonly' => true, 'filemtime' => EDC('nocache') ? null : $filemtime])) # => true means not modified (no new data fetched) { $success = true; - $isnewfile = it_url::_atomicwrite($path, $p['assoc'] ? serialize($data) : $data); + $isnewfile = it_url::_atomicwrite($path, $p['assoc'] ? it::json_encode($data) : $data); if ($p['returnheaders']) it::file_put("$path.json", it::json_encode($url->headers)); } @@ -719,7 +719,7 @@ static function get_cache_contents($p) $result = it::file_get_contents($fn); if ($p['assoc']) { - $response = unserialize($result); + $response = it::match('^\{', $result) ? it::json_decode($result, 'assoc' => true) : unserialize($result); # FIXME 2023-05 UM remove legacy support $response['data'] = self::_postprocess($response['data'], $p); $result = $response; } |