Merge pull request #6788 from rxu/ticket/17480-2

[ticket/17480] Properly catch RuntimeException if no http handler is available
This commit is contained in:
Marc Alexander 2025-03-08 09:00:35 +01:00 committed by GitHub
commit 57abba6be0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View file

@ -357,6 +357,7 @@ $lang = array_merge($lang, array(
'HIDE_ME' => 'Hide my online status this session', 'HIDE_ME' => 'Hide my online status this session',
'HOURS' => 'Hours', 'HOURS' => 'Hours',
'HOME' => 'Home', 'HOME' => 'Home',
'HTTP_HANDLER_NOT_FOUND' => 'The operation could not be completed because the cURL PHP extension and allow_url_fopen PHP ini setting have been disabled and no other HTTP handler could be found.',
'ICQ' => 'ICQ', 'ICQ' => 'ICQ',
'IF' => 'If', 'IF' => 'If',

View file

@ -75,8 +75,15 @@ class file_downloader
*/ */
public function get(string $host, string $directory, string $filename, int $port = 443, int $timeout = 6) public function get(string $host, string $directory, string $filename, int $port = 443, int $timeout = 6)
{ {
// Initialize Guzzle client try
$client = $this->create_client($host, $port, $timeout); {
// Initialize Guzzle client
$client = $this->create_client($host, $port, $timeout);
}
catch (\RuntimeException $exception)
{
throw new runtime_exception('HTTP_HANDLER_NOT_FOUND');
}
// Set default values for error variables // Set default values for error variables
$this->error_number = 0; $this->error_number = 0;