diff options
| -rw-r--r-- | app/Models/SimplePieResponse.php | 2 | ||||
| -rw-r--r-- | lib/composer.json | 2 | ||||
| -rw-r--r-- | lib/simplepie/simplepie/src/File.php | 22 |
3 files changed, 15 insertions, 11 deletions
diff --git a/app/Models/SimplePieResponse.php b/app/Models/SimplePieResponse.php index 6a444a86a..322145d2b 100644 --- a/app/Models/SimplePieResponse.php +++ b/app/Models/SimplePieResponse.php @@ -4,7 +4,7 @@ declare(strict_types=1); final class FreshRSS_SimplePieResponse extends \SimplePie\File { #[\Override] - protected function on_http_response(string|false $response = ''): void { + protected function on_http_response($response = ''): void { syslog(LOG_INFO, 'FreshRSS SimplePie GET ' . $this->get_status_code() . ' ' . \SimplePie\Misc::url_remove_credentials($this->get_final_requested_uri())); if (in_array($this->get_status_code(), [429, 503], true)) { diff --git a/lib/composer.json b/lib/composer.json index b0b4dd1cf..2eebbc7e4 100644 --- a/lib/composer.json +++ b/lib/composer.json @@ -14,7 +14,7 @@ "marienfressinaud/lib_opml": "0.5.1", "phpgt/cssxpath": "v1.3.0", "phpmailer/phpmailer": "6.10.0", - "simplepie/simplepie": "dev-freshrss#dcaa720d3d8bc8202333f569c4cddb4a407dc213" + "simplepie/simplepie": "dev-freshrss#24fc939c10b3b8d3d486a4f467bbb9d8c98a6878" }, "config": { "sort-packages": true, diff --git a/lib/simplepie/simplepie/src/File.php b/lib/simplepie/simplepie/src/File.php index 4a8cb157c..ba078ae4e 100644 --- a/lib/simplepie/simplepie/src/File.php +++ b/lib/simplepie/simplepie/src/File.php @@ -137,21 +137,23 @@ class File implements Response curl_setopt($fp, $curl_param, $curl_value); } + /** @var string|false $responseHeaders */ $responseHeaders = curl_exec($fp); if (curl_errno($fp) === CURLE_WRITE_ERROR || curl_errno($fp) === CURLE_BAD_CONTENT_ENCODING) { $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp); // FreshRSS - $this->on_http_response(); + $this->on_http_response($responseHeaders); $this->error = null; // FreshRSS curl_setopt($fp, CURLOPT_ENCODING, 'none'); + /** @var string|false $responseHeaders */ $responseHeaders = curl_exec($fp); } $this->status_code = curl_getinfo($fp, CURLINFO_HTTP_CODE); if (curl_errno($fp)) { $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp); $this->success = false; - $this->on_http_response(); + $this->on_http_response($responseHeaders); } else { - $this->on_http_response(); + $this->on_http_response($responseHeaders); // Use the updated url provided by curl_getinfo after any redirects. if ($info = curl_getinfo($fp)) { $this->url = $info['url']; @@ -199,7 +201,7 @@ class File implements Response if (!$fp) { $this->error = 'fsockopen error: ' . $errstr; $this->success = false; - $this->on_http_response(); + $this->on_http_response(false); } else { stream_set_timeout($fp, $timeout); if (isset($url_parts['path'])) { @@ -240,7 +242,7 @@ class File implements Response $this->set_headers($parser->headers); $this->body = $parser->body; $this->status_code = $parser->status_code; - $this->on_http_response(); + $this->on_http_response($responseHeaders); if ((in_array($this->status_code, [300, 301, 302, 303, 307]) || $this->status_code > 307 && $this->status_code < 400) && ($locationHeader = $this->get_header_line('location')) !== '' && $this->redirects < $redirects) { $this->redirects++; $location = \SimplePie\Misc::absolutize_url($locationHeader, $url); @@ -288,18 +290,19 @@ class File implements Response } else { $this->error = 'Could not parse'; // FreshRSS $this->success = false; // FreshRSS - $this->on_http_response(); + $this->on_http_response($responseHeaders); } } else { $this->error = 'fsocket timed out'; $this->success = false; - $this->on_http_response(); + $this->on_http_response($responseHeaders); } fclose($fp); } } } else { $this->method = \SimplePie\SimplePie::FILE_SOURCE_LOCAL | \SimplePie\SimplePie::FILE_SOURCE_FILE_GET_CONTENTS; + $filebody = false; if (empty($url) || !is_readable($url) || false === $filebody = file_get_contents($url)) { $this->body = ''; $this->error = sprintf('file "%s" is not readable', $url); @@ -308,7 +311,7 @@ class File implements Response $this->body = $filebody; $this->status_code = 200; } - $this->on_http_response(); + $this->on_http_response($filebody); } if ($this->success) { assert($this->body !== null); // For PHPStan @@ -322,9 +325,10 @@ class File implements Response /** * Event to allow inheriting classes to e.g. log the HTTP responses. * Triggered just after an HTTP response is received. + * @param string|false $response The raw HTTP response headers and body, or false in case of failure (as returned by curl_exec()). * FreshRSS. */ - protected function on_http_response(): void + protected function on_http_response($response): void { } |
