Skip to content

Commit b465170

Browse files
committed
Fixed merge conflict
1 parent 68a7f70 commit b465170

File tree

1 file changed

+23
-49
lines changed

1 file changed

+23
-49
lines changed

src/Elasticsearch/Connections/Connection.php

Lines changed: 23 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -249,25 +249,11 @@ private function wrapHandler(callable $handler): callable
249249
$options
250250
);
251251
}
252-
253-
$this->log->warning("Out of retries, throwing exception from $node");
254-
// Only throw if we run out of retries
255-
throw $exception;
256-
} else {
257-
// Something went seriously wrong, bail
258-
$exception = new TransportException($response['error']->getMessage());
259-
$this->logRequestFail(
260-
$request['http_method'],
261-
$response['effective_url'],
262-
$request['body'],
263-
$request['headers'],
264-
(int) $response['status'],
265-
$response['body'],
266-
(float) $response['transfer_stats']['total_time'],
267-
$exception
268-
);
269-
throw $exception;
270252
}
253+
254+
$this->log->warning("Out of retries, throwing exception from $node");
255+
// Only throw if we run out of retries
256+
throw $exception;
271257
} else {
272258
// Something went seriously wrong, bail
273259
$exception = new TransportException($response['error']->getMessage());
@@ -277,38 +263,26 @@ private function wrapHandler(callable $handler): callable
277263
} else {
278264
$connection->markAlive();
279265

280-
if (isset($response['body']) === true) {
281-
$response['body'] = stream_get_contents($response['body']);
282-
$this->lastRequest['response']['body'] = $response['body'];
283-
}
266+
if (isset($response['body']) === true) {
267+
$response['body'] = stream_get_contents($response['body']);
268+
$this->lastRequest['response']['body'] = $response['body'];
269+
}
284270

285-
if ($response['status'] >= 400 && $response['status'] < 500) {
286-
$ignore = $request['client']['ignore'] ?? [];
287-
// Skip 404 if succeeded true in the body (e.g. clear_scroll)
288-
$body = $response['body'] ?? '';
289-
if (strpos($body, '"succeeded":true') !== false) {
290-
$ignore[] = 404;
291-
}
292-
$this->process4xxError($request, $response, $ignore);
293-
} elseif ($response['status'] >= 500) {
294-
$ignore = $request['client']['ignore'] ?? [];
295-
$this->process5xxError($request, $response, $ignore);
271+
if ($response['status'] >= 400 && $response['status'] < 500) {
272+
$ignore = $request['client']['ignore'] ?? [];
273+
// Skip 404 if succeeded true in the body (e.g. clear_scroll)
274+
$body = $response['body'] ?? '';
275+
if (strpos($body, '"succeeded":true') !== false) {
276+
$ignore[] = 404;
296277
}
297-
298-
// No error, deserialize
299-
$response['body'] = $this->serializer->deserialize($response['body'], $response['transfer_stats']);
278+
$this->process4xxError($request, $response, $ignore);
279+
} elseif ($response['status'] >= 500) {
280+
$ignore = $request['client']['ignore'] ?? [];
281+
$this->process5xxError($request, $response, $ignore);
300282
}
301-
$this->logRequestSuccess(
302-
$request['http_method'],
303-
$response['effective_url'],
304-
$request['body'],
305-
$request['headers'],
306-
(int) $response['status'],
307-
(array) $response['body'],
308-
(float) $response['transfer_stats']['total_time']
309-
);
310-
311-
return isset($request['client']['verbose']) && $request['client']['verbose'] === true ? $response : $response['body'];
283+
284+
// No error, deserialize
285+
$response['body'] = $this->serializer->deserialize($response['body'], $response['transfer_stats']);
312286
}
313287
$this->logRequestSuccess($request, $response);
314288

@@ -350,7 +324,7 @@ function (&$value, &$key) {
350324
* @param array $response
351325
* @return void
352326
*/
353-
public function logRequestSuccess($request, $response)
327+
public function logRequestSuccess(array $request, array $response): void
354328
{
355329
$this->log->debug('Request Body', array($request['body']));
356330
$this->log->info(
@@ -389,7 +363,7 @@ public function logRequestSuccess($request, $response)
389363
*
390364
* @return void
391365
*/
392-
public function logRequestFail($request, $response, \Exception $exception)
366+
public function logRequestFail(array $request, array $response, \Exception $exception): void
393367
{
394368
$this->log->debug('Request Body', array($request['body']));
395369
$this->log->warning(

0 commit comments

Comments
 (0)