Skip to content

Commit b36ade7

Browse files
fix: address Copilot review feedback
- Default bypass_product_check to true so OpenSearch works out-of-the-box - Remove unused \$apiVersion assignment in Bulk::_processResponse() - Remove duplicate native_constant_invocation rule from CS config - Fix Request context in Pipeline::deletePipeline() catch (DELETE method + full path) - Fix Request context in Reindex::run() catch (POST method + body) - Add array|string type to Client::__construct \$config parameter Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a9abab4 commit b36ade7

6 files changed

Lines changed: 8 additions & 8 deletions

File tree

.php-cs-fixer.dist.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
'@Symfony' => true,
1616
'is_null' => true,
1717
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
18-
'native_constant_invocation' => true,
1918
'native_function_invocation' => false,
2019
'no_alias_functions' => true,
2120
'no_useless_else' => true,

src/Bulk.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ protected function _processResponse(Response $response): ResponseSet
311311
case 413: throw new RequestEntityTooLargeException();
312312
}
313313

314-
$apiVersion = $this->_client->getApiVersion();
315314
$responseData = $response->getData();
316315

317316
$actions = $this->getActions();

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class Client
8888
* @throws InvalidException
8989
*/
9090
public function __construct(
91-
$config = [],
91+
array|string $config = [],
9292
$callback = null,
9393
?LoggerInterface $logger = null,
9494
?RequestCounterInterface $requestCounter = null,

src/Connection.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,11 @@ public function getClient(): ElasticsearchClient
307307

308308
$stack = HandlerStack::create();
309309

310-
// When connecting to OpenSearch (which does not send the X-Elastic-Product header
311-
// required by elasticsearch-php v9), set bypass_product_check=true in connection params.
312-
if ($this->hasParam('bypass_product_check') && $this->getParam('bypass_product_check')) {
310+
// Inject X-Elastic-Product header by default so OpenSearch clusters (which do not send
311+
// this header) pass the elasticsearch-php v9 product check. Set bypass_product_check=false
312+
// to disable this behaviour when strict product verification is required.
313+
$bypassProductCheck = !$this->hasParam('bypass_product_check') || $this->getParam('bypass_product_check');
314+
if ($bypassProductCheck) {
313315
$stack->push(Middleware::mapResponse(
314316
static function (ResponseInterface $response): ResponseInterface {
315317
return $response->withHeader('X-Elastic-Product', 'Elasticsearch');

src/Pipeline.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function deletePipeline(string $id): Response
101101
$bodyStream->rewind();
102102
}
103103
$elasticaResponse = new Response((string) $bodyStream, $psrResponse->getStatusCode());
104-
throw new ResponseException(new Request($id), $elasticaResponse);
104+
throw new ResponseException(new Request('_ingest/pipeline/'.$id, Request::DELETE), $elasticaResponse);
105105
}
106106

107107
return new Response($esResponse->asArray(), $esResponse->getStatusCode());

src/Reindex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function run(): Response
9292
$bodyStream->rewind();
9393
}
9494
$elasticaResponse = new Response((string) $bodyStream, $psrResponse->getStatusCode());
95-
throw new ResponseException(new Request('_reindex'), $elasticaResponse);
95+
throw new ResponseException(new Request('_reindex', Request::POST, $body), $elasticaResponse);
9696
}
9797
$this->_lastResponse = new Response($esResponse->asArray(), $esResponse->getStatusCode());
9898

0 commit comments

Comments
 (0)