From b6433ede122ddfbf539f91659480c16abe851e8c Mon Sep 17 00:00:00 2001 From: JiaJia Ji Date: Mon, 26 Aug 2024 11:55:04 +0200 Subject: [PATCH] [Task]: Replace Request::get with explicit input sources (#874) * request explicit source * Apply php-cs-fixer changes * Update 01_Upgrade_Notes.md * fix tests workflows --------- Co-authored-by: kingjia90 --- .github/workflows/codeception.yml | 6 ++--- .github/workflows/static-analysis.yml | 6 ++--- composer.json | 16 ++++++------- .../01_Upgrade_Notes.md | 4 ++++ src/Controller/ConfigController.php | 24 +++++++++---------- src/Controller/GraphQLExplorerController.php | 2 +- src/Controller/WebserviceController.php | 10 ++------ .../CheckConsumerPermissionsService.php | 2 +- src/Service/OutputCacheService.php | 4 ++-- 9 files changed, 35 insertions(+), 39 deletions(-) diff --git a/.github/workflows/codeception.yml b/.github/workflows/codeception.yml index f14236a4..2376366a 100644 --- a/.github/workflows/codeception.yml +++ b/.github/workflows/codeception.yml @@ -34,9 +34,9 @@ jobs: strategy: matrix: include: - - { php-version: 8.0, database: "mariadb:10.3", dependencies: lowest, experimental: false, require_admin_bundle: false } - - { php-version: 8.3, database: "mariadb:10.11", dependencies: highest, experimental: false, require_admin_bundle: true } - - { php-version: 8.3, database: "mariadb:10.11", dependencies: highest, pimcore_version: "11.x-dev as 11.0.0", experimental: true, require_admin_bundle: true } + - { php-version: 8.1, database: "mariadb:10.3", dependencies: lowest, experimental: false, require_admin_bundle: false } + - { php-version: 8.2, database: "mariadb:10.11", dependencies: highest, experimental: false, require_admin_bundle: true } + - { php-version: 8.3, database: "mariadb:10.11", dependencies: highest, pimcore_version: "11.x-dev", experimental: true, require_admin_bundle: true } services: redis: image: redis diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 2e0b3706..2d7ff3a9 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -25,9 +25,9 @@ jobs: strategy: matrix: include: - - { php-version: "8.0", dependencies: "lowest", require_admin_bundle: false } - - { php-version: "8.3", dependencies: "highest", require_admin_bundle: true } - - { php-version: "8.3", dependencies: "highest", pimcore_version: "11.x-dev as 11.0.0", phpstan_args: "", experimental: true, require_admin_bundle: true } + - { php-version: "8.1", dependencies: "lowest", require_admin_bundle: false } + - { php-version: "8.2", dependencies: "highest", require_admin_bundle: true } + - { php-version: "8.3", dependencies: "highest", pimcore_version: "11.x-dev", phpstan_args: "", experimental: true, require_admin_bundle: true } steps: - name: "Checkout code" uses: "actions/checkout@v2" diff --git a/composer.json b/composer.json index 6d9f18d0..4765e446 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,9 @@ "prefer-stable": true, "minimum-stability": "dev", "require": { - "php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", - "pimcore/pimcore": "^10.6.8 || ^11.0.7", + "php": "~8.1.0 || ~8.2.0 || ~8.3.0", + "pimcore/admin-ui-classic-bundle": "^1.0", + "pimcore/pimcore": "^11.2", "pimcore/compatibility-bridge-v10": "^1.0", "webonyx/graphql-php": "^15.2.3" }, @@ -25,15 +26,12 @@ "phpstan/phpstan": "^1.9", "phpunit/phpunit": "^9.6", "symfony/phpunit-bridge": "^6", - "codeception/codeception": "^4.1.12 || ^5.0.3", + "codeception/codeception": "^5.0.3", "codeception/phpunit-wrapper": "^9", "codeception/module-asserts": "^2", - "codeception/module-symfony": "^1.6.0 || ^3.1.0", - "symfony/dotenv": "^6.2 || ^5.4.21", - "symfony/runtime": "^6.4 || ^5.4" - }, - "suggest": { - "pimcore/admin-ui-classic-bundle": "Required for Pimcore 11" + "codeception/module-symfony": "^3.1.0", + "symfony/dotenv": "^6.2", + "symfony/runtime": "^6.4" }, "autoload": { "psr-4": { diff --git a/doc/01_Installation_and_Upgrade/01_Upgrade_Notes.md b/doc/01_Installation_and_Upgrade/01_Upgrade_Notes.md index 4148dadd..8ce4d7ad 100644 --- a/doc/01_Installation_and_Upgrade/01_Upgrade_Notes.md +++ b/doc/01_Installation_and_Upgrade/01_Upgrade_Notes.md @@ -1,5 +1,9 @@ # Upgrade Notes +## 1.8.0 +- [General] Dropped support of `pimcore/pimcore` v10. Bumped minimum requirement of `pimcore/pimcore` to `^11.2` +- [General] Replaced Request::get() with explicit input sources. + ## 1.7.0 - [GraphQL] Deprecated SQL Condition. - [GraphQL] Added the possibility to disable deprecated SQL Condition. diff --git a/src/Controller/ConfigController.php b/src/Controller/ConfigController.php index 9fd8e877..1a5a9d4a 100644 --- a/src/Controller/ConfigController.php +++ b/src/Controller/ConfigController.php @@ -141,7 +141,7 @@ public function deleteAction(Request $request): ?JsonResponse } try { - $name = $request->get('name'); + $name = $request->query->getString('name'); $config = Configuration::getByName($name); if (!$config instanceof Configuration) { @@ -178,9 +178,9 @@ public function addAction(Request $request): ?JsonResponse } try { - $path = $request->get('path'); - $name = $request->get('name'); - $type = $request->get('type'); + $path = $request->query->getString('path'); + $name = $request->query->getString('name'); + $type = $request->query->getString('type'); $this->checkPermissionsHasOneOf(['plugin_datahub_admin', 'plugin_datahub_adapter_' . $type]); $config = Configuration::getByName($name); @@ -208,14 +208,14 @@ public function cloneAction(Request $request): ?JsonResponse $this->checkPermission(self::CONFIG_NAME); try { - $name = $request->get('name'); + $name = $request->query->getString('name'); $config = Configuration::getByName($name); if ($config instanceof Configuration) { throw new \Exception('Name already exists.'); } - $originalName = $request->get('originalName'); + $originalName = $request->query->getString('originalName'); $originalConfig = Configuration::getByName($originalName); if (!$originalConfig) { throw new \Exception('Configuration not found'); @@ -246,7 +246,7 @@ public function getAction(Request $request, Service $graphQlService, EventDispat { $this->checkPermission(self::CONFIG_NAME); - $name = $request->get('name'); + $name = $request->query->getString('name'); $configuration = Configuration::getByName($name); if (!$configuration) { @@ -396,8 +396,8 @@ public function saveAction(Request $request): ?JsonResponse $this->checkPermission(self::CONFIG_NAME); try { - $data = $request->get('data'); - $modificationDate = $request->get('modificationDate', 0); + $data = $request->request->getString('data'); + $modificationDate = $request->request->getInt('modificationDate', 0); $dataDecoded = json_decode($data, true); @@ -474,7 +474,7 @@ public function saveAction(Request $request): ?JsonResponse */ public function getExplorerUrlAction(RouterInterface $routingService, Request $request): ?JsonResponse { - $name = $request->get('name'); + $name = $request->query->getString('name'); $url = $routingService->generate('admin_pimcoredatahub_config', ['clientname' => $name]); if ($url) { @@ -515,7 +515,7 @@ public function thumbnailTreeAction(Request $request) */ public function getPermissionUsersAction(Request $request) { - $type = $request->get('type', 'user'); + $type = $request->query->getString('type', 'user'); $list = new User\Listing(); if ($type === 'role') { @@ -548,7 +548,7 @@ public function exportConfiguration(Request $request, ExportService $exportServi { $this->checkPermission(self::CONFIG_NAME); - $name = $request->get('name'); + $name = $request->query->getString('name'); $configuration = Configuration::getByName($name); if (!$configuration) { throw new \Exception('Datahub configuration ' . $name . ' does not exist.'); diff --git a/src/Controller/GraphQLExplorerController.php b/src/Controller/GraphQLExplorerController.php index 3f299e28..a0cd82d9 100644 --- a/src/Controller/GraphQLExplorerController.php +++ b/src/Controller/GraphQLExplorerController.php @@ -32,7 +32,7 @@ public function explorerAction(RouterInterface $routingService, Request $request { $urlParams = array_merge($request->request->all(), $request->query->all()); - $clientName = $request->get('clientname'); + $clientName = $request->attributes->getString('clientname'); $url = $routingService->generate('admin_pimcoredatahub_webservice', ['clientname' => $clientName]); diff --git a/src/Controller/WebserviceController.php b/src/Controller/WebserviceController.php index 9e9694fe..ba9786e8 100644 --- a/src/Controller/WebserviceController.php +++ b/src/Controller/WebserviceController.php @@ -92,7 +92,7 @@ public function webonyxAction( Request $request, LongRunningHelper $longRunningHelper ) { - $clientname = $request->get('clientname'); + $clientname = $request->attributes->getString('clientname'); $configuration = Configuration::getByName($clientname); if (!$configuration || !$configuration->isActive()) { @@ -167,12 +167,6 @@ public function webonyxAction( $rootValue = []; $validators = null; - if ($request->get('novalidate')) { - // disable all validators except the listed ones - $validators = [ -// new NoUndefinedVariables() - ]; - } $event = new ExecutorEvent( $request, @@ -184,7 +178,7 @@ public function webonyxAction( $this->eventDispatcher->dispatch($event, ExecutorEvents::PRE_EXECUTE); if ($event->getRequest() instanceof Request) { - $variableValues = $event->getRequest()->get('variables', $variableValues); + $variableValues = $event->getRequest()->request->get('variables', $variableValues); } $configAllowIntrospection = true; diff --git a/src/Service/CheckConsumerPermissionsService.php b/src/Service/CheckConsumerPermissionsService.php index 34e2bbfd..9aa0a1ed 100644 --- a/src/Service/CheckConsumerPermissionsService.php +++ b/src/Service/CheckConsumerPermissionsService.php @@ -31,7 +31,7 @@ public function performSecurityCheck(Request $request, Configuration $configurat $apiKey = $request->headers->get(static::TOKEN_HEADER); } if (empty($apiKey)) { - $apiKey = $request->get('apikey'); + $apiKey = $request->query->getString('apikey'); } if (is_array($securityConfig['apikey'])) { return in_array($apiKey, $securityConfig['apikey']); diff --git a/src/Service/OutputCacheService.php b/src/Service/OutputCacheService.php index 623aacd4..ac3c95a1 100644 --- a/src/Service/OutputCacheService.php +++ b/src/Service/OutputCacheService.php @@ -82,7 +82,7 @@ public function save(Request $request, JsonResponse $response, $extraTags = []): { if ($this->useCache($request)) { $cacheKey = $this->computeKey($request); - $clientname = $request->get('clientname'); + $clientname = $request->attributes->getString('clientname'); $extraTags = array_merge(['output', 'datahub', $clientname], $extraTags); $event = new OutputCachePreSaveEvent($request, $response); @@ -115,7 +115,7 @@ protected function saveToCache($key, $item, $tags = []): void private function computeKey(Request $request): string { - $clientname = $request->get('clientname'); + $clientname = $request->attributes->getString('clientname'); $input = json_decode($request->getContent(), true); $input = print_r($input, true);