Skip to content

Commit 9e013c1

Browse files
author
MartinBeranek
committed
Merge branch 'master' into gemmel/numeric-conversion-fix
2 parents a71946f + 5fb2b77 commit 9e013c1

4 files changed

Lines changed: 17 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
44

55
## [Unreleased][unreleased]
66

7-
## 3.4.1
7+
## 3.4.2
8+
### Fixed
9+
* Input validation before authorization check in ApiPresenter (causes issues with some authorization handlers that need to check input params)
810

11+
## 3.4.1
912
### Fixed
10-
- Don't overwrite global preflight handler if it is set and enableGlobalPreflight is called without parameter
13+
* Don't overwrite global preflight handler if it is set and enableGlobalPreflight is called without parameter
1114

1215
## 3.4.0
1316

src/Component/ApiConsoleControl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function formSucceeded(Form $form, ArrayHash $values): void
104104
$template = $this->getTemplate();
105105
$template->add('response', $result);
106106

107-
if ($this->getPresenter()?->isAjax()) {
107+
if ($this->getPresenter()->isAjax()) {
108108
$this->getPresenter()->redrawControl();
109109
}
110110
}

src/Handlers/OpenApiHandler.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ private function getPaths(array $versionApis, string $baseUrl, string $basePath)
342342
} else {
343343
foreach ($examples as $exampleKey => $example) {
344344
$example = is_array($example) ? $example : json_decode($example, true);
345-
/** @phpstan-ignore-next-line */
346345
$responses[$output->getCode()]['content']['application/json; charset=utf-8']['examples'][$exampleKey] = $example;
347346
}
348347
}

src/Presenters/ApiPresenter.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,19 @@ public function run(Request $request): IResponse
8585
}
8686

8787
$paramsProcessor = new ParamsProcessor($handler->params());
88-
if ($paramsProcessor->isError()) {
89-
$response = $this->errorHandler->handleInputParams($paramsProcessor->getErrors());
90-
$this->response->setCode($response->getCode());
91-
return $response;
92-
}
93-
94-
$params = $paramsProcessor->getValues();
88+
$params = $paramsProcessor->isError() ? [] : $paramsProcessor->getValues();
9589

9690
$authResponse = $this->checkAuth($authorization, $params);
9791
if ($authResponse !== null) {
9892
return $authResponse;
9993
}
10094

95+
if ($paramsProcessor->isError()) {
96+
$response = $this->errorHandler->handleInputParams($paramsProcessor->getErrors());
97+
$this->response->setCode($response->getCode());
98+
return $response;
99+
}
100+
101101
try {
102102
$response = $handler->handle($params);
103103
$code = $response->getCode();
@@ -145,7 +145,7 @@ private function getApi(Request $request): Api
145145
$request->getMethod() ?? '',
146146
$request->getParameter('version'),
147147
$request->getParameter('package'),
148-
$request->getParameter('apiAction')
148+
$request->getParameter('apiAction'),
149149
);
150150
}
151151

@@ -216,10 +216,10 @@ private function logRequest(Request $request, ApiLoggerInterface $logger, int $c
216216
$code,
217217
$request->getMethod() ?? '',
218218
$requestHeaders,
219-
(string) filter_input(INPUT_SERVER, 'REQUEST_URI'),
219+
(string)filter_input(INPUT_SERVER, 'REQUEST_URI'),
220220
$ipDetector->getRequestIp(),
221-
(string) filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'),
222-
(int) ($elapsed * self::TO_SECONDS)
221+
(string)filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'),
222+
(int)($elapsed * self::TO_SECONDS),
223223
);
224224
}
225225

0 commit comments

Comments
 (0)