Verified Commit 8c89656b authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3189301 by Spokje, xjm, smustgrave: Use...

Issue #3189301 by Spokje, xjm, smustgrave: Use \Psr\Http\Client\ClientExceptionInterface instead of \GuzzleHttp\Exception\TransferException
parent e94e1d77
Loading
Loading
Loading
Loading
Loading
+4 −3
Changes for core/includes/install.core.inc: 4 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -35,12 +35,12 @@
use Drupal\language\ConfigurableLanguageManagerInterface;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Core\Routing\RouteObjectInterface;
use Psr\Http\Client\ClientExceptionInterface;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Route;
use Drupal\user\Entity\User;
use GuzzleHttp\Exception\TransferException;

/**
 * Do not run the task during the current installation request.
@@ -1446,9 +1446,10 @@ function install_retrieve_file($uri, $destination) {
      return FALSE;
    }
  }
  catch (TransferException $e) {
  catch (ClientExceptionInterface) {
    return FALSE;
  }

  return file_put_contents($path, $data) !== FALSE;
}

@@ -1466,7 +1467,7 @@ function install_check_localization_server($uri) {
    \Drupal::httpClient()->head($uri);
    return TRUE;
  }
  catch (TransferException $e) {
  catch (ClientExceptionInterface) {
    return FALSE;
  }
}
+2 −2
Changes for core/modules/locale/locale.batch.inc: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@
use Drupal\Core\Url;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Exception\TransferException;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UriInterface;
@@ -354,7 +354,7 @@ function locale_translation_download_source($source_file, $directory = 'temporar
      return $file;
    }
  }
  catch (TransferException $exception) {
  catch (ClientExceptionInterface $exception) {
    \Drupal::messenger()->addError(t('Failed to fetch file due to error "%error"', ['%error' => $exception->getMessage()]));
  }
  catch (FileException | InvalidStreamWrapperException $e) {
+2 −2
Changes for core/modules/media/src/OEmbed/ProviderRepository.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@
use Drupal\Core\KeyValueStore\KeyValueFactoryInterface;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\TransferException;
use Psr\Http\Client\ClientExceptionInterface;

/**
 * Retrieves and caches information about oEmbed providers.
@@ -100,7 +100,7 @@ public function getAll() {
    try {
      $response = $this->httpClient->request('GET', $this->providersUrl);
    }
    catch (TransferException $e) {
    catch (ClientExceptionInterface  $e) {
      if (isset($stored['data'])) {
        // Use the stale data to fall back gracefully, but warn site
        // administrators that we used stale data.
+2 −2
Changes for core/modules/media/src/OEmbed/ResourceFetcher.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -5,8 +5,8 @@
use Drupal\Component\Serialization\Json;
use Drupal\Core\Cache\CacheBackendInterface;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\TransferException;
use GuzzleHttp\RequestOptions;
use Psr\Http\Client\ClientExceptionInterface;

// cspell:ignore nocdata

@@ -68,7 +68,7 @@ public function fetchResource($url) {
        RequestOptions::TIMEOUT => 5,
      ]);
    }
    catch (TransferException $e) {
    catch (ClientExceptionInterface $e) {
      throw new ResourceException('Could not retrieve the oEmbed resource.', $url, [], $e);
    }

+2 −2
Changes for core/modules/media/src/OEmbed/UrlResolver.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\TransferException;
use Psr\Http\Client\ClientExceptionInterface;

// cspell:ignore omitscript

@@ -96,7 +96,7 @@ protected function discoverResourceUrl($url) {
    try {
      $response = $this->httpClient->get($url);
    }
    catch (TransferException $e) {
    catch (ClientExceptionInterface) {
      return FALSE;
    }

Loading