From 0601e5612fb87886d2cfc954f6b7cf38959ef1d4 Mon Sep 17 00:00:00 2001 From: Marco Perberschlager Date: Wed, 4 Sep 2024 08:36:43 +0200 Subject: [PATCH 1/4] Removed default value from request->get --- src/Controller/WebserviceController.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Controller/WebserviceController.php b/src/Controller/WebserviceController.php index ba9786e8..1b9b90ff 100644 --- a/src/Controller/WebserviceController.php +++ b/src/Controller/WebserviceController.php @@ -93,6 +93,7 @@ public function webonyxAction( LongRunningHelper $longRunningHelper ) { $clientname = $request->attributes->getString('clientname'); + $variableValues = null; $configuration = Configuration::getByName($clientname); if (!$configuration || !$configuration->isActive()) { @@ -161,7 +162,7 @@ public function webonyxAction( } $query = $input['query'] ?? ''; - $variableValues = $input['variables'] ?? null; + try { $rootValue = []; @@ -178,7 +179,11 @@ public function webonyxAction( $this->eventDispatcher->dispatch($event, ExecutorEvents::PRE_EXECUTE); if ($event->getRequest() instanceof Request) { - $variableValues = $event->getRequest()->request->get('variables', $variableValues); + $variableValues = $event->getRequest()->request->get('variables'); + } + + if(empty($variableValues)) { + $variableValues = $input['variables'] ?? null; } $configAllowIntrospection = true; From c2eeed4d1313bbd85eba9b1982029cf05fe21d5f Mon Sep 17 00:00:00 2001 From: mcop1 Date: Wed, 4 Sep 2024 06:39:00 +0000 Subject: [PATCH 2/4] Apply php-cs-fixer changes --- src/Controller/WebserviceController.php | 3 +-- src/GraphQL/DataObjectInputProcessor/Table.php | 2 +- tests/GraphQL/ResolveTest.php | 12 ++++++------ tests/_support/Helper/Service.php | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Controller/WebserviceController.php b/src/Controller/WebserviceController.php index 1b9b90ff..8ffc7f79 100644 --- a/src/Controller/WebserviceController.php +++ b/src/Controller/WebserviceController.php @@ -163,7 +163,6 @@ public function webonyxAction( $query = $input['query'] ?? ''; - try { $rootValue = []; @@ -182,7 +181,7 @@ public function webonyxAction( $variableValues = $event->getRequest()->request->get('variables'); } - if(empty($variableValues)) { + if (empty($variableValues)) { $variableValues = $input['variables'] ?? null; } diff --git a/src/GraphQL/DataObjectInputProcessor/Table.php b/src/GraphQL/DataObjectInputProcessor/Table.php index 6a4aba2c..041faf07 100644 --- a/src/GraphQL/DataObjectInputProcessor/Table.php +++ b/src/GraphQL/DataObjectInputProcessor/Table.php @@ -46,7 +46,7 @@ public function process($object, $newValue, $args, $context, ResolveInfo $info) $attribute = $this->getAttribute(); $objectBrickParts = Service::parseObjectBrickFieldName($attribute); - if(empty($objectBrickParts)) { + if (empty($objectBrickParts)) { $getter = 'get' . ucfirst($attribute); $currentTable = $object->$getter(); } else { diff --git a/tests/GraphQL/ResolveTest.php b/tests/GraphQL/ResolveTest.php index fe6c7d8d..58e270eb 100644 --- a/tests/GraphQL/ResolveTest.php +++ b/tests/GraphQL/ResolveTest.php @@ -38,7 +38,7 @@ public function testGraphQLTranslationListingResolveListing() $translationListing = new TranslationListing($this->service, new EventDispatcher()); $listRes = $translationListing->resolveListing([], []); - for($i = 0; $i < 4; $i++) { + for ($i = 0; $i < 4; $i++) { $this->assertEquals('translation-k' .$i, $listRes['edges'][$i]['cursor']); $translation = $listRes['edges'][$i]['node']; @@ -53,7 +53,7 @@ public function testGraphQLTranslationListingResolveListingWithDomain() $translationListing = new TranslationListing($this->service, new EventDispatcher()); $listRes = $translationListing->resolveListing([], ['domain' => 'admin']); - for($i = 0; $i < 2; $i++) { + for ($i = 0; $i < 2; $i++) { $this->assertEquals('translation-ka' .$i, $listRes['edges'][$i]['cursor']); $translation = $listRes['edges'][$i]['node']; @@ -85,7 +85,7 @@ public function testGraphQLTranslationListingResolveListingWithKeys() $translationListing = new TranslationListing($this->service, new EventDispatcher()); $listRes = $translationListing->resolveListing([], ['keys' => $keys]); - for($i = 0; $i < 2; $i++) { + for ($i = 0; $i < 2; $i++) { $this->assertEquals('translation-k' .$i + 1, $listRes['edges'][$i]['cursor']); $translation = $listRes['edges'][$i]['node']; @@ -128,7 +128,7 @@ public function testGraphQLTranslationListingResolveListingWithLanguagesAndKeys( $translationListing = new TranslationListing($this->service, new EventDispatcher()); $listRes = $translationListing->resolveListing([], ['languages' => $languages, 'keys' => $keys]); - for($i = 0; $i < 2; $i++) { + for ($i = 0; $i < 2; $i++) { $translation = $listRes['edges'][$i]['node']; $translations = $translation->getTranslations(); @@ -149,10 +149,10 @@ public function testGraphQLResolveTranslationGetter() private function addTranslations(): void { - for($i = 0; $i < 4; $i++) { + for ($i = 0; $i < 4; $i++) { $this->addTranslation('k' . $i); } - for($i = 0; $i < 2; $i++) { + for ($i = 0; $i < 2; $i++) { $this->addTranslation('ka' . $i, 'admin'); $this->addTranslation('ka' . $i, 'admin'); } diff --git a/tests/_support/Helper/Service.php b/tests/_support/Helper/Service.php index d8449e8a..773eeb26 100644 --- a/tests/_support/Helper/Service.php +++ b/tests/_support/Helper/Service.php @@ -33,7 +33,7 @@ public function grabService(string $serviceId) { //TODO change this as soon as Pimcore helper as grabService method and requirement is bumped to pimcore/pimcore:10.4 - if(empty(self::$container)) { + if (empty(self::$container)) { $container = \Pimcore::getContainer(); self::$container = $container->has('test.service_container') ? $container->get('test.service_container') : $container; } From 633ea397698201f25101a710ea87a04b94445ce2 Mon Sep 17 00:00:00 2001 From: mcop1 <89011527+mcop1@users.noreply.github.com> Date: Wed, 4 Sep 2024 11:29:32 +0200 Subject: [PATCH 3/4] Update src/Controller/WebserviceController.php Co-authored-by: Sebastian Blank --- src/Controller/WebserviceController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controller/WebserviceController.php b/src/Controller/WebserviceController.php index 8ffc7f79..1694d24d 100644 --- a/src/Controller/WebserviceController.php +++ b/src/Controller/WebserviceController.php @@ -181,7 +181,7 @@ public function webonyxAction( $variableValues = $event->getRequest()->request->get('variables'); } - if (empty($variableValues)) { + if (!$variableValues) { $variableValues = $input['variables'] ?? null; } From b987a550756989478a5b5e0f023d1a6ca6a1fcb6 Mon Sep 17 00:00:00 2001 From: Marco Perberschlager Date: Wed, 4 Sep 2024 11:37:17 +0200 Subject: [PATCH 4/4] Using all instead of get because of the array type --- src/Controller/WebserviceController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controller/WebserviceController.php b/src/Controller/WebserviceController.php index 1694d24d..5a26f818 100644 --- a/src/Controller/WebserviceController.php +++ b/src/Controller/WebserviceController.php @@ -178,7 +178,7 @@ public function webonyxAction( $this->eventDispatcher->dispatch($event, ExecutorEvents::PRE_EXECUTE); if ($event->getRequest() instanceof Request) { - $variableValues = $event->getRequest()->request->get('variables'); + $variableValues = $event->getRequest()->request->all('variables'); } if (!$variableValues) {