Skip to content

Commit 1aa4a0e

Browse files
authored
Merge pull request #35798 from nextcloud/backport/35780/stable25
[stable25] Fix missing cast of double controller parameters
2 parents af246d6 + e8619fe commit 1aa4a0e

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

lib/private/AppFramework/Http/Dispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ private function executeController(Controller $controller, string $methodName):
194194
$arguments = [];
195195

196196
// valid types that will be casted
197-
$types = ['int', 'integer', 'bool', 'boolean', 'float'];
197+
$types = ['int', 'integer', 'bool', 'boolean', 'float', 'double'];
198198

199199
foreach ($this->reflector->getParameters() as $param => $default) {
200200

tests/lib/AppFramework/Http/DispatcherTest.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ public function __construct($appName, $request) {
5151
/**
5252
* @param int $int
5353
* @param bool $bool
54+
* @param double $foo
5455
* @param int $test
55-
* @param int $test2
56+
* @param integer $test2
5657
* @return array
5758
*/
58-
public function exec($int, $bool, $test = 4, $test2 = 1) {
59+
public function exec($int, $bool, $foo, $test = 4, $test2 = 1) {
5960
$this->registerResponder('text', function ($in) {
6061
return new JSONResponse(['text' => $in]);
6162
});
@@ -315,7 +316,8 @@ public function testControllerParametersInjected() {
315316
[
316317
'post' => [
317318
'int' => '3',
318-
'bool' => 'false'
319+
'bool' => 'false',
320+
'double' => 1.2,
319321
],
320322
'method' => 'POST'
321323
],
@@ -346,6 +348,7 @@ public function testControllerParametersInjectedDefaultOverwritten() {
346348
'post' => [
347349
'int' => '3',
348350
'bool' => 'false',
351+
'double' => 1.2,
349352
'test2' => 7
350353
],
351354
'method' => 'POST',
@@ -377,7 +380,8 @@ public function testResponseTransformedByUrlFormat() {
377380
[
378381
'post' => [
379382
'int' => '3',
380-
'bool' => 'false'
383+
'bool' => 'false',
384+
'double' => 1.2,
381385
],
382386
'urlParams' => [
383387
'format' => 'text'
@@ -410,7 +414,8 @@ public function testResponseTransformsDataResponse() {
410414
[
411415
'post' => [
412416
'int' => '3',
413-
'bool' => 'false'
417+
'bool' => 'false',
418+
'double' => 1.2,
414419
],
415420
'urlParams' => [
416421
'format' => 'json'
@@ -443,7 +448,8 @@ public function testResponseTransformedByAcceptHeader() {
443448
[
444449
'post' => [
445450
'int' => '3',
446-
'bool' => 'false'
451+
'bool' => 'false',
452+
'double' => 1.2,
447453
],
448454
'server' => [
449455
'HTTP_ACCEPT' => 'application/text, test',
@@ -477,7 +483,8 @@ public function testResponsePrimarilyTransformedByParameterFormat() {
477483
[
478484
'post' => [
479485
'int' => '3',
480-
'bool' => 'false'
486+
'bool' => 'false',
487+
'double' => 1.2,
481488
],
482489
'get' => [
483490
'format' => 'text'

0 commit comments

Comments
 (0)