From 07bd4d876ac027853e5dc4f0fca0481c35cc4932 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Thu, 25 Apr 2024 09:07:40 +0200 Subject: Revert "Switch it_url::get('assoc' => true) to always return non-empty array including at least the HTTP status code" This reverts commit d4bd73f98063ebbdf6c6f5ce94252360de901c9a. --- it_url.class | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'it_url.class') diff --git a/it_url.class b/it_url.class index 91dfbf4..637990c 100644 --- a/it_url.class +++ b/it_url.class @@ -150,7 +150,7 @@ function _get($p = []) usleep($p['fetchsleep'] * 1000000); if ($p['assoc']) - $result = [ 'status' => intval($this->result) ?: 503, 'data' => $result !== false ? $this->data : null, 'headers' => $this->headers, 'cookies' => $this->cookies, 'errstr' => $this->errstr ]; + $result = $result !== false ? [ 'status' => $this->result, 'data' => $this->data, 'headers' => $this->headers, 'cookies' => $this->cookies, 'errstr' => $this->errstr ] : []; EDC('curlinfo', $this->result, $this->headers, $this->cookies, $this->errstr); @@ -615,8 +615,7 @@ static function get_cache($p = array()) EDC('getcache', "new", $filemtime, $p['url'], $path); $url = new it_url; - $response = $url->_get($p + ['checkonly' => true, 'filemtime' => EDC('nocache') ? null : $filemtime]); - if ($data = $p['assoc'] ? $response['data'] : $response) # $data === true means not modified (no new data fetched) + 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'] ? it::json_encode($data) : $data); -- cgit v1.2.3