Skip to content

Commit

Permalink
[Task]: Replace Request::get with explicit input sources (#874)
Browse files Browse the repository at this point in the history
* request explicit source

* Apply php-cs-fixer changes

* Update 01_Upgrade_Notes.md

* fix tests workflows

---------

Co-authored-by: kingjia90 <[email protected]>
  • Loading branch information
kingjia90 and kingjia90 authored Aug 26, 2024
1 parent e5bb884 commit b6433ed
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 39 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeception.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 7 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,22 @@
"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"
},
"require-dev": {
"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": {
Expand Down
4 changes: 4 additions & 0 deletions doc/01_Installation_and_Upgrade/01_Upgrade_Notes.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
24 changes: 12 additions & 12 deletions src/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -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.');
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/GraphQLExplorerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
10 changes: 2 additions & 8 deletions src/Controller/WebserviceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Service/CheckConsumerPermissionsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
4 changes: 2 additions & 2 deletions src/Service/OutputCacheService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b6433ed

Please sign in to comment.