From 8e1f7ab3fccc5328854ad280d639debae7747324 Mon Sep 17 00:00:00 2001 From: Richard BAYET Date: Wed, 19 Jul 2023 08:09:12 +0200 Subject: [PATCH] #1242562 [Elasticsearch] Prevent automatic ES requests during model API calls --- api/composer.json | 3 +++ .../api-platform-elasticsearch-bridge.patch | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 api/patches/api-platform-elasticsearch-bridge.patch diff --git a/api/composer.json b/api/composer.json index 2269054d8..7191528f8 100644 --- a/api/composer.json +++ b/api/composer.json @@ -122,6 +122,9 @@ "patches": { "lexik/jwt-authentication-bundle": { "Fix forward port of trait that does not preload correctly": "patches/jwt-authenticator.patch" + }, + "api-platform/core": { + "Fix Elasticsearch bridge data providers enabled by default": "patches/api-platform-elasticsearch-bridge.patch" } } } diff --git a/api/patches/api-platform-elasticsearch-bridge.patch b/api/patches/api-platform-elasticsearch-bridge.patch new file mode 100644 index 000000000..505da72ff --- /dev/null +++ b/api/patches/api-platform-elasticsearch-bridge.patch @@ -0,0 +1,26 @@ +diff --git a/src/Bridge/Elasticsearch/DataProvider/CollectionDataProvider.php b/src/Bridge/Elasticsearch/DataProvider/CollectionDataProvider.php +index b69f0083a..e410c10bd 100644 +--- a/src/Bridge/Elasticsearch/DataProvider/CollectionDataProvider.php ++++ b/src/Bridge/Elasticsearch/DataProvider/CollectionDataProvider.php +@@ -64,7 +64,7 @@ final class CollectionDataProvider implements ContextAwareCollectionDataProvider + { + try { + $resourceMetadata = $this->resourceMetadataFactory->create($resourceClass); +- if (false === $resourceMetadata->getCollectionOperationAttribute($operationName, 'elasticsearch', true, true)) { ++ if (false === $resourceMetadata->getCollectionOperationAttribute($operationName, 'elasticsearch', false, true)) { + return false; + } + } catch (ResourceClassNotFoundException $e) { +diff --git a/src/Bridge/Elasticsearch/DataProvider/ItemDataProvider.php b/src/Bridge/Elasticsearch/DataProvider/ItemDataProvider.php +index 9d3fcb1c7..4cce1b9a2 100644 +--- a/src/Bridge/Elasticsearch/DataProvider/ItemDataProvider.php ++++ b/src/Bridge/Elasticsearch/DataProvider/ItemDataProvider.php +@@ -58,7 +58,7 @@ final class ItemDataProvider implements ItemDataProviderInterface, RestrictedDat + { + try { + $resourceMetadata = $this->resourceMetadataFactory->create($resourceClass); +- if (false === $resourceMetadata->getItemOperationAttribute($operationName, 'elasticsearch', true, true)) { ++ if (false === $resourceMetadata->getItemOperationAttribute($operationName, 'elasticsearch', false, true)) { + return false; + } + } catch (ResourceClassNotFoundException $e) {