@@ -2943,19 +2943,31 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
29432943 private function registerCachingHttpClient (array $ options , array $ defaultOptions , string $ name , ContainerBuilder $ container ): void
29442944 {
29452945 if (!class_exists (ChunkCacheItemNotFoundException::class)) {
2946- throw new LogicException ('Caching cannot be enabled as version 7.3 + of the HttpClient component is required. ' );
2946+ throw new LogicException ('Caching cannot be enabled as version 7.4 + of the HttpClient component is required. ' );
29472947 }
29482948
29492949 $ container
29502950 ->register ($ name .'.caching ' , CachingHttpClient::class)
2951- ->setDecoratedService ($ name , null , 13 ) // between RetryableHttpClient (10) and ThrottlingHttpClient (15)
29522951 ->setArguments ([
29532952 new Reference ($ name .'.caching.inner ' ),
29542953 new Reference ($ options ['cache_pool ' ]),
29552954 $ defaultOptions ,
29562955 $ options ['shared ' ],
29572956 $ options ['max_ttl ' ],
29582957 ]);
2958+
2959+ $ httpClient = $ container ->getDefinition ($ name );
2960+
2961+ if (ScopingHttpClient::class === $ httpClient ->getClass ()) {
2962+ $ httpClient ->setDecoratedService ($ name .'.caching ' , null , 13 ); // between RetryableHttpClient (10) and ThrottlingHttpClient (15)
2963+
2964+ $ container ->getDefinition ($ name .'.caching ' )
2965+ ->replaceArgument (0 , $ httpClient ->getArgument (0 ));
2966+ } else {
2967+ $ container
2968+ ->getDefinition ($ name .'.caching ' )
2969+ ->setDecoratedService ($ name , null , 13 ); // between RetryableHttpClient (10) and ThrottlingHttpClient (15)
2970+ }
29592971 }
29602972
29612973 private function registerThrottlingHttpClient (string $ rateLimiter , string $ name , ContainerBuilder $ container ): void
0 commit comments