From 2f182277f5ddad3fb88d88827bf5e0db7b0f5b30 Mon Sep 17 00:00:00 2001 From: Timothy PREFOL Date: Tue, 20 Aug 2024 14:48:57 +0200 Subject: [PATCH 1/6] allow es8 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2cb7d49a7..53e42938b 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "php": "^7.4 || ^8.0", "pagerfanta/pagerfanta": "^2.4 || ^3.0 || ^4.0", "psr/log": "^1.0 || ^2.0 || ^3.0", - "ruflin/elastica": "^7.1", + "ruflin/elastica": "^7.1 || ^8.0", "symfony/console": "^5.4 || ^6.4 || ^7.0", "symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0", "symfony/framework-bundle": "^5.4 || ^6.4 || ^7.0", From a79223fefc10f404e859051bb79d93858b7348d9 Mon Sep 17 00:00:00 2001 From: Timothy PREFOL Date: Tue, 20 Aug 2024 15:03:48 +0200 Subject: [PATCH 2/6] Rework client --- src/DependencyInjection/FOSElasticaExtension.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/DependencyInjection/FOSElasticaExtension.php b/src/DependencyInjection/FOSElasticaExtension.php index 24663bd20..64bb63aaf 100644 --- a/src/DependencyInjection/FOSElasticaExtension.php +++ b/src/DependencyInjection/FOSElasticaExtension.php @@ -166,11 +166,10 @@ private function loadClients(array $clients, ContainerBuilder $container): void $clientDef = new ChildDefinition('fos_elastica.client_prototype'); $clientDef->replaceArgument(0, $clientConfig); - $clientDef->replaceArgument(1, null); $logger = $clientConfig['connections'][0]['logger']; if (false !== $logger) { - $clientDef->addMethodCall('setLogger', [new Reference($logger)]); + $clientDef->replaceArgument(1, new Reference($logger)); } $clientDef->addTag('fos_elastica.client'); From fcbd21fb53f3229d015fc4ea8f48d8cf234437b7 Mon Sep 17 00:00:00 2001 From: Timothy PREFOL Date: Tue, 20 Aug 2024 16:52:16 +0200 Subject: [PATCH 3/6] Client WIP --- src/Elastica/Client.php | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/Elastica/Client.php b/src/Elastica/Client.php index 85ece7b96..744095777 100644 --- a/src/Elastica/Client.php +++ b/src/Elastica/Client.php @@ -12,6 +12,7 @@ namespace FOS\ElasticaBundle\Elastica; use Elastica\Client as BaseClient; +use Elastica\ClientConfiguration; use Elastica\Exception\ClientException; use Elastica\Exception\ExceptionInterface; use Elastica\Index as BaseIndex; @@ -60,7 +61,13 @@ public function request(string $path, string $method = Request::GET, $data = [], } try { - $response = parent::request($path, $method, $data, $query, $contentType); + + $headers = [ + 'Content-Type' => $contentType, + ]; + $request = $this->createRequest($method, $path, $headers, $query); + $es = parent::sendRequest($request); + $response = new Response($es->asString(), $es->getStatusCode()); } catch (ExceptionInterface $e) { $this->logQuery($path, $method, $data, $query, 0, 0, 0); throw $e; @@ -68,20 +75,25 @@ public function request(string $path, string $method = Request::GET, $data = [], $responseData = $response->getData(); - $transportInfo = $response->getTransferInfo(); - $connection = $this->getLastRequest()->getConnection(); - $forbiddenHttpCodes = $connection->hasConfig('http_error_codes') ? $connection->getConfig('http_error_codes') : []; + $statusCode = $response->getStatus(); + $connections = $this->_config->get('connections'); + $forbiddenHttpCodes = []; + if(!empty($connections)) { + $connection = $connections[0]; + $forbiddenHttpCodes = $connection['http_error_codes'] ?? []; + + } - if (isset($transportInfo['http_code']) && \in_array($transportInfo['http_code'], $forbiddenHttpCodes, true)) { + if (\in_array($statusCode, $forbiddenHttpCodes, true)) { $body = \json_encode($responseData); - $message = \sprintf('Error in transportInfo: response code is %s, response body is %s', $transportInfo['http_code'], $body); + $message = \sprintf('Error in transportInfo: response code is %s, response body is %s', $statusCode, $body); throw new ClientException($message); } if (isset($responseData['took'], $responseData['hits'])) { - $this->logQuery($path, $method, $data, $query, $response->getQueryTime(), $response->getEngineTime(), $responseData['hits']['total']['value'] ?? 0); +// $this->logQuery($path, $method, $data, $query, $response->getQueryTime(), $response->getEngineTime(), $responseData['hits']['total']['value'] ?? 0); timtodo } else { - $this->logQuery($path, $method, $data, $query, $response->getQueryTime(), 0, 0); +// $this->logQuery($path, $method, $data, $query, $response->getQueryTime(), 0, 0); timtodo } if ($this->stopwatch) { From a2c964114f7d2e9a65a67f4b2ebfddca171dc550 Mon Sep 17 00:00:00 2001 From: Timothy PREFOL Date: Thu, 22 Aug 2024 13:43:45 +0200 Subject: [PATCH 4/6] es8 wip --- src/Elastica/Client.php | 23 ++++++++++++----------- src/Finder/TransformedFinder.php | 5 +++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Elastica/Client.php b/src/Elastica/Client.php index 744095777..56a97fec8 100644 --- a/src/Elastica/Client.php +++ b/src/Elastica/Client.php @@ -61,11 +61,11 @@ public function request(string $path, string $method = Request::GET, $data = [], } try { - $headers = [ 'Content-Type' => $contentType, + 'Accept' => $contentType, ]; - $request = $this->createRequest($method, $path, $headers, $query); + $request = $this->createRequest($method, $path, $headers, $data); $es = parent::sendRequest($request); $response = new Response($es->asString(), $es->getStatusCode()); } catch (ExceptionInterface $e) { @@ -78,10 +78,9 @@ public function request(string $path, string $method = Request::GET, $data = [], $statusCode = $response->getStatus(); $connections = $this->_config->get('connections'); $forbiddenHttpCodes = []; - if(!empty($connections)) { + if (!empty($connections)) { $connection = $connections[0]; $forbiddenHttpCodes = $connection['http_error_codes'] ?? []; - } if (\in_array($statusCode, $forbiddenHttpCodes, true)) { @@ -91,9 +90,9 @@ public function request(string $path, string $method = Request::GET, $data = [], } if (isset($responseData['took'], $responseData['hits'])) { -// $this->logQuery($path, $method, $data, $query, $response->getQueryTime(), $response->getEngineTime(), $responseData['hits']['total']['value'] ?? 0); timtodo + $this->logQuery($path, $method, $data, $query, $responseData['took'], $response->getEngineTime(), $responseData['hits']['total']['value'] ?? 0); } else { -// $this->logQuery($path, $method, $data, $query, $response->getQueryTime(), 0, 0); timtodo + $this->logQuery($path, $method, $data, $query, $responseData['took'] ?? 0, 0, 0); } if ($this->stopwatch) { @@ -140,13 +139,15 @@ private function logQuery(string $path, string $method, $data, array $query, $qu return; } - $connection = $this->getLastRequest()->getConnection(); + $connections = $this->_config->get('connections'); + + $connection = $connections[0]; $connectionArray = [ - 'host' => $connection->getHost(), - 'port' => $connection->getPort(), - 'transport' => $connection->getTransport(), - 'headers' => $connection->hasConfig('headers') ? $connection->getConfig('headers') : [], + 'host' => $connection['host'] ?? null, + 'port' => $connection['port'] ?? null, + 'transport' => $connection['transport'] ?? null, + 'headers' => $connection['headers'] ?? [], ]; $this->_logger->logQuery($path, $method, $data, $queryTime, $connectionArray, $query, $engineMS, $itemCount); diff --git a/src/Finder/TransformedFinder.php b/src/Finder/TransformedFinder.php index 3294d597f..d6df448e6 100644 --- a/src/Finder/TransformedFinder.php +++ b/src/Finder/TransformedFinder.php @@ -30,6 +30,7 @@ class TransformedFinder implements PaginatedFinderInterface, PaginatedRawFinderInterface, PaginatedHybridFinderInterface { protected SearchableInterface $searchable; + protected ElasticaToModelTransformerInterface $transformer; public function __construct(SearchableInterface $searchable, ElasticaToModelTransformerInterface $transformer) @@ -100,10 +101,10 @@ public function createRawPaginatorAdapter($query, array $options = []) } /** - * @phpstan-param TQuery $query + * @phpstan-param TQuery $query * @phpstan-param TOptions $options * - * @param mixed $query + * @param mixed $query * * @return Result[] */ From 7511e5d43d97d6b4db5b11a1e5b30b52804f39ef Mon Sep 17 00:00:00 2001 From: Timothy PREFOL Date: Fri, 23 Aug 2024 10:22:28 +0200 Subject: [PATCH 5/6] Rework collector Fix tests --- src/Elastica/Client.php | 37 +++--- tests/Unit/Command/CreateCommandTest.php | 25 ++--- tests/Unit/Index/AliasProcessorTest.php | 136 ++++++++++++++--------- 3 files changed, 114 insertions(+), 84 deletions(-) diff --git a/src/Elastica/Client.php b/src/Elastica/Client.php index 56a97fec8..1b2d5dd45 100644 --- a/src/Elastica/Client.php +++ b/src/Elastica/Client.php @@ -11,14 +11,15 @@ namespace FOS\ElasticaBundle\Elastica; +use Elastic\Elasticsearch\Response\Elasticsearch; use Elastica\Client as BaseClient; -use Elastica\ClientConfiguration; use Elastica\Exception\ClientException; use Elastica\Exception\ExceptionInterface; use Elastica\Index as BaseIndex; use Elastica\Request; use Elastica\Response; use FOS\ElasticaBundle\Logger\ElasticaLogger; +use Psr\Http\Message\RequestInterface; use Symfony\Component\Stopwatch\Stopwatch; /** @@ -50,26 +51,32 @@ class Client extends BaseClient */ private $stopwatch; - /** - * @param array $data - * @param array $query - */ - public function request(string $path, string $method = Request::GET, $data = [], array $query = [], string $contentType = Request::DEFAULT_CONTENT_TYPE): Response + public function request(string $path, string $method = Request::GET, $data = [], string $contentType = Request::DEFAULT_CONTENT_TYPE): Response + { + $headers = [ + 'Content-Type' => $contentType, + 'Accept' => $contentType, + ]; + + $request = $this->createRequest($method, $path, $headers, $data); + $es = $this->sendRequest($request); + + return new Response($es->asString(), $es->getStatusCode()); + } + + public function sendRequest(RequestInterface $request): Elasticsearch { if ($this->stopwatch) { $this->stopwatch->start('es_request', 'fos_elastica'); } + $query = $request->getBody()->__toString(); + try { - $headers = [ - 'Content-Type' => $contentType, - 'Accept' => $contentType, - ]; - $request = $this->createRequest($method, $path, $headers, $data); $es = parent::sendRequest($request); $response = new Response($es->asString(), $es->getStatusCode()); } catch (ExceptionInterface $e) { - $this->logQuery($path, $method, $data, $query, 0, 0, 0); + $this->logQuery($request->getUri(), $request->getMethod(), [], $query, 0, 0, 0); throw $e; } @@ -90,16 +97,16 @@ public function request(string $path, string $method = Request::GET, $data = [], } if (isset($responseData['took'], $responseData['hits'])) { - $this->logQuery($path, $method, $data, $query, $responseData['took'], $response->getEngineTime(), $responseData['hits']['total']['value'] ?? 0); + $this->logQuery($request->getUri(), $request->getMethod(), $query, [], $responseData['took'], $response->getEngineTime(), $responseData['hits']['total']['value'] ?? 0); } else { - $this->logQuery($path, $method, $data, $query, $responseData['took'] ?? 0, 0, 0); + $this->logQuery($request->getUri(), $request->getMethod(), $query, [], $responseData['took'] ?? 0, 0, 0); } if ($this->stopwatch) { $this->stopwatch->stop('es_request'); } - return $response; + return $es; } public function getIndex(string $name): BaseIndex diff --git a/tests/Unit/Command/CreateCommandTest.php b/tests/Unit/Command/CreateCommandTest.php index fa32262d5..537ea2b7a 100644 --- a/tests/Unit/Command/CreateCommandTest.php +++ b/tests/Unit/Command/CreateCommandTest.php @@ -93,8 +93,7 @@ public function testExecuteWithIndexProvidedAndWithAlias() ->expects($this->exactly(2)) ->method('getOption') ->withConsecutive(['index'], ['no-alias']) - ->willReturnOnConsecutiveCalls($indexName, false) - ; + ->willReturnOnConsecutiveCalls($indexName, false); $output->expects($this->once())->method('writeln'); $this->configManager->expects($this->once())->method('getIndexConfiguration')->with($indexName)->willReturn($this->indexConfig); $this->indexManager->expects($this->once())->method('getIndex')->with($indexName)->willReturn($this->index); @@ -102,7 +101,7 @@ public function testExecuteWithIndexProvidedAndWithAlias() $this->indexConfig->expects($this->once())->method('getElasticSearchName')->willReturn($indexName); $this->aliasProcessor->expects($this->once())->method('setRootName')->with($this->indexConfig, $this->index); $this->mappingBuilder->expects($this->once())->method('buildIndexMapping')->with($this->indexConfig)->willReturn($mapping); - $this->index->expects($this->once())->method('create')->with(['mapping'], false); + $this->index->expects($this->once())->method('create')->with(['mapping']); $this->index->expects($this->once())->method('addAlias')->with($indexName); $this->command->run($input, $output); @@ -120,15 +119,14 @@ public function testExecuteWithIndexProvidedAndWithAliasButDisabled() ->expects($this->exactly(2)) ->method('getOption') ->withConsecutive(['index'], ['no-alias']) - ->willReturnOnConsecutiveCalls($indexName, true) - ; + ->willReturnOnConsecutiveCalls($indexName, true); $output->expects($this->once())->method('writeln'); $this->configManager->expects($this->once())->method('getIndexConfiguration')->with($indexName)->willReturn($this->indexConfig); $this->indexManager->expects($this->once())->method('getIndex')->with($indexName)->willReturn($this->index); $this->indexConfig->expects($this->exactly(2))->method('isUseAlias')->willReturn(true); $this->aliasProcessor->expects($this->once())->method('setRootName')->with($this->indexConfig, $this->index); $this->mappingBuilder->expects($this->once())->method('buildIndexMapping')->with($this->indexConfig)->willReturn($mapping); - $this->index->expects($this->once())->method('create')->with(['mapping'], false); + $this->index->expects($this->once())->method('create')->with(['mapping']); $this->index->expects($this->never())->method('addAlias')->with($indexName); $this->command->run($input, $output); @@ -149,7 +147,7 @@ public function testExecuteWithIndexProvidedAndWithoutAlias() $this->indexConfig->expects($this->exactly(2))->method('isUseAlias')->willReturn(false); $this->aliasProcessor->expects($this->never())->method('setRootName'); $this->mappingBuilder->expects($this->once())->method('buildIndexMapping')->with($this->indexConfig)->willReturn($mapping); - $this->index->expects($this->once())->method('create')->with(['mapping'], false); + $this->index->expects($this->once())->method('create')->with(['mapping']); $this->index->expects($this->never())->method('addAlias'); $this->command->run($input, $output); @@ -174,13 +172,11 @@ public function testExecuteAllIndices() $this->configManager->expects($this->exactly(2))->method('getIndexConfiguration') ->withConsecutive(['foo'], ['bar']) - ->willReturnOnConsecutiveCalls($indexConfig1, $indexConfig2) - ; + ->willReturnOnConsecutiveCalls($indexConfig1, $indexConfig2); $this->indexManager->expects($this->exactly(2))->method('getIndex') ->withConsecutive(['foo'], ['bar']) - ->willReturnOnConsecutiveCalls($index1, $index2) - ; + ->willReturnOnConsecutiveCalls($index1, $index2); $indexConfig1->expects($this->exactly(2))->method('isUseAlias')->willReturn(false); $indexConfig2->expects($this->exactly(2))->method('isUseAlias')->willReturn(false); @@ -189,12 +185,11 @@ public function testExecuteAllIndices() $this->mappingBuilder->expects($this->exactly(2))->method('buildIndexMapping') ->withConsecutive([$indexConfig1], [$indexConfig2]) - ->willReturn($mapping) - ; + ->willReturn($mapping); - $index1->expects($this->once())->method('create')->with(['mapping'], false); + $index1->expects($this->once())->method('create')->with(['mapping']); $index1->expects($this->never())->method('addAlias'); - $index2->expects($this->once())->method('create')->with(['mapping'], false); + $index2->expects($this->once())->method('create')->with(['mapping']); $index2->expects($this->never())->method('addAlias'); $this->command->run($input, $output); diff --git a/tests/Unit/Index/AliasProcessorTest.php b/tests/Unit/Index/AliasProcessorTest.php index 8dae9c265..7e33f668d 100644 --- a/tests/Unit/Index/AliasProcessorTest.php +++ b/tests/Unit/Index/AliasProcessorTest.php @@ -11,11 +11,10 @@ namespace FOS\ElasticaBundle\Tests\Unit\Index; -use Elastica\Client; -use Elastica\Exception\ResponseException; -use Elastica\Request; +use Elastica\Exception\NotFoundException; use Elastica\Response; use FOS\ElasticaBundle\Configuration\IndexConfig; +use FOS\ElasticaBundle\Elastica\Client; use FOS\ElasticaBundle\Elastica\Index; use FOS\ElasticaBundle\Exception\AliasIsIndexException; use FOS\ElasticaBundle\Index\AliasProcessor; @@ -40,7 +39,7 @@ protected function setUp(): void /** * @dataProvider getSetRootNameData * - * @param array $configArray + * @param array $configArray * @param string $resultStartsWith */ public function testSetRootName($configArray, $resultStartsWith) @@ -49,8 +48,7 @@ public function testSetRootName($configArray, $resultStartsWith) $index = $this->createMock(Index::class); $index->expects($this->once()) ->method('overrideName') - ->with($this->stringStartsWith($resultStartsWith)) - ; + ->with($this->stringStartsWith($resultStartsWith)); $this->processor->setRootName($indexConfig, $index); } @@ -64,12 +62,17 @@ public function testSwitchAliasNoAliasSet() ->method('request') ->withConsecutive( ['_aliases', 'GET'], - ['_aliases', 'POST', ['actions' => [ - ['add' => ['index' => 'unique_name', 'alias' => 'name']], - ]]] + [ + '_aliases', + 'POST', + [ + 'actions' => [ + ['add' => ['index' => 'unique_name', 'alias' => 'name']], + ], + ], + ] ) - ->willReturn(new Response([])) - ; + ->willReturn(new Response([])); $this->processor->switchIndexAlias($indexConfig, $index, false); } @@ -83,18 +86,23 @@ public function testSwitchAliasExistingAliasSet() ->method('request') ->withConsecutive( ['_aliases', 'GET'], - ['_aliases', 'POST', ['actions' => [ - ['remove' => ['index' => 'old_unique_name', 'alias' => 'name']], - ['add' => ['index' => 'unique_name', 'alias' => 'name']], - ]]], + [ + '_aliases', + 'POST', + [ + 'actions' => [ + ['remove' => ['index' => 'old_unique_name', 'alias' => 'name']], + ['add' => ['index' => 'unique_name', 'alias' => 'name']], + ], + ], + ], ['old_unique_name', 'DELETE'] ) ->willReturnOnConsecutiveCalls( new Response(['old_unique_name' => ['aliases' => ['name' => []]]]), new Response([]), new Response([]) - ) - ; + ); $this->processor->switchIndexAlias($indexConfig, $index, false); } @@ -107,11 +115,12 @@ public function testSwitchAliasThrowsWhenMoreThanOneExists() $client->expects($this->once()) ->method('request') ->with('_aliases', 'GET') - ->willReturn(new Response([ - 'old_unique_name' => ['aliases' => ['name' => []]], - 'another_old_unique_name' => ['aliases' => ['name' => []]], - ])) - ; + ->willReturn( + new Response([ + 'old_unique_name' => ['aliases' => ['name' => []]], + 'another_old_unique_name' => ['aliases' => ['name' => []]], + ]) + ); $this->expectException(\RuntimeException::class); $this->processor->switchIndexAlias($indexConfig, $index, false); @@ -125,10 +134,11 @@ public function testSwitchAliasThrowsWhenAliasIsAnIndex() $client->expects($this->once()) ->method('request') ->with('_aliases', 'GET') - ->willReturn(new Response([ - 'name' => [], - ])) - ; + ->willReturn( + new Response([ + 'name' => [], + ]) + ); $this->expectException(AliasIsIndexException::class); $this->processor->switchIndexAlias($indexConfig, $index, false); @@ -144,16 +154,21 @@ public function testSwitchAliasDeletesIndexCollisionIfForced() ->withConsecutive( ['_aliases', 'GET'], ['name', 'DELETE'], - ['_aliases', 'POST', ['actions' => [ - ['add' => ['index' => 'unique_name', 'alias' => 'name']], - ]]] + [ + '_aliases', + 'POST', + [ + 'actions' => [ + ['add' => ['index' => 'unique_name', 'alias' => 'name']], + ], + ], + ] ) ->willReturnOnConsecutiveCalls( new Response(['name' => []]), new Response([]), new Response([]) - ) - ; + ); $this->processor->switchIndexAlias($indexConfig, $index, true); } @@ -167,18 +182,23 @@ public function testSwitchAliasCloseOldIndex() ->method('request') ->withConsecutive( ['_aliases', 'GET'], - ['_aliases', 'POST', ['actions' => [ - ['remove' => ['index' => 'old_unique_name', 'alias' => 'name']], - ['add' => ['index' => 'unique_name', 'alias' => 'name']], - ]]], + [ + '_aliases', + 'POST', + [ + 'actions' => [ + ['remove' => ['index' => 'old_unique_name', 'alias' => 'name']], + ['add' => ['index' => 'unique_name', 'alias' => 'name']], + ], + ], + ], ['old_unique_name/_close', 'POST'] ) ->willReturnOnConsecutiveCalls( new Response(['old_unique_name' => ['aliases' => ['name' => []]]]), new Response([]), new Response([]) - ) - ; + ); $this->processor->switchIndexAlias($indexConfig, $index, true, false); } @@ -192,18 +212,23 @@ public function testSwitchAliasDeletesOldIndex() ->method('request') ->withConsecutive( ['_aliases', 'GET'], - ['_aliases', 'POST', ['actions' => [ - ['remove' => ['index' => 'old_unique_name', 'alias' => 'name']], - ['add' => ['index' => 'unique_name', 'alias' => 'name']], - ]]], + [ + '_aliases', + 'POST', + [ + 'actions' => [ + ['remove' => ['index' => 'old_unique_name', 'alias' => 'name']], + ['add' => ['index' => 'unique_name', 'alias' => 'name']], + ], + ], + ], ['old_unique_name', 'DELETE'] ) ->willReturnOnConsecutiveCalls( new Response(['old_unique_name' => ['aliases' => ['name' => []]]]), new Response([]), new Response([]) - ) - ; + ); $this->processor->switchIndexAlias($indexConfig, $index, true); } @@ -217,18 +242,23 @@ public function testSwitchAliasCleansUpOnRenameFailure() ->method('request') ->withConsecutive( ['_aliases', 'GET'], - ['_aliases', 'POST', ['actions' => [ - ['remove' => ['index' => 'old_unique_name', 'alias' => 'name']], - ['add' => ['index' => 'unique_name', 'alias' => 'name']], - ]]], + [ + '_aliases', + 'POST', + [ + 'actions' => [ + ['remove' => ['index' => 'old_unique_name', 'alias' => 'name']], + ['add' => ['index' => 'unique_name', 'alias' => 'name']], + ], + ], + ], ['unique_name', 'DELETE'] ) ->willReturnOnConsecutiveCalls( new Response(['old_unique_name' => ['aliases' => ['name' => []]]]), - $this->throwException(new ResponseException(new Request(''), new Response(''))), + $this->throwException(new NotFoundException('')), new Response([]) - ) - ; + ); $this->expectException(\RuntimeException::class); @@ -253,13 +283,11 @@ private function getMockedIndex(string $name): array $index->expects($this->any()) ->method('getClient') - ->willReturn($client) - ; + ->willReturn($client); $index->expects($this->any()) ->method('getName') - ->willReturn($name) - ; + ->willReturn($name); return [$index, $client]; } From c92c40c29c22e52041562a73f96a3731a78d2f6b Mon Sep 17 00:00:00 2001 From: Timothy PREFOL Date: Fri, 23 Aug 2024 10:42:22 +0200 Subject: [PATCH 6/6] Log query arguments --- src/Elastica/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Elastica/Client.php b/src/Elastica/Client.php index 1b2d5dd45..692682bd1 100644 --- a/src/Elastica/Client.php +++ b/src/Elastica/Client.php @@ -76,7 +76,7 @@ public function sendRequest(RequestInterface $request): Elasticsearch $es = parent::sendRequest($request); $response = new Response($es->asString(), $es->getStatusCode()); } catch (ExceptionInterface $e) { - $this->logQuery($request->getUri(), $request->getMethod(), [], $query, 0, 0, 0); + $this->logQuery($request->getUri(), $request->getMethod(), $query, [], 0, 0, 0); throw $e; }