Skip to content

Commit 6e86c24

Browse files
Merge branch '6.3' into 6.4
* 6.3: [FrameworkBundle] Fixed parsing new JSON output of debug:config not possible [DependencyInjection] Skip errored definitions deep-referenced as runtime exceptions [AssetMapper] Allow DirectoryResource for cache [PhpUnitBridge] Require PHPUnit 9.6 by default [WebProfilerBundle] Fix the accessibility of some background color [HttpKernel] Nullable and default value arguments in RequestPayloadValueResolver [WebProfilerBundle] right blocks: fix display [Messenger] Preserve existing Doctrine schema [Serializer] Refactor tests to not extends ObjectNormalizer [HttpFoundation] Make Request::getPayload() return an empty InputBag if request body is empty [HttpClient] Explicitly exclude CURLOPT_POSTREDIR [FrameworkBundle] Fix setting decorated services during tests
2 parents a9cb76a + e0ad0d1 commit 6e86c24

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

Request.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,25 @@ public function getContent(bool $asResource = false)
15131513
*/
15141514
public function getPayload(): InputBag
15151515
{
1516-
return $this->request->count() ? clone $this->request : new InputBag($this->toArray());
1516+
if ($this->request->count()) {
1517+
return clone $this->request;
1518+
}
1519+
1520+
if ('' === $content = $this->getContent()) {
1521+
return new InputBag([]);
1522+
}
1523+
1524+
try {
1525+
$content = json_decode($content, true, 512, \JSON_BIGINT_AS_STRING | \JSON_THROW_ON_ERROR);
1526+
} catch (\JsonException $e) {
1527+
throw new JsonException('Could not decode request body.', $e->getCode(), $e);
1528+
}
1529+
1530+
if (!\is_array($content)) {
1531+
throw new JsonException(sprintf('JSON content was expected to decode to an array, "%s" returned.', get_debug_type($content)));
1532+
}
1533+
1534+
return new InputBag($content);
15171535
}
15181536

15191537
/**

Session/Storage/Handler/SessionHandlerFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Doctrine\DBAL\DriverManager;
1616
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
1717
use Doctrine\DBAL\Tools\DsnParser;
18-
use Doctrine\ORM\ORMSetup;
1918
use Relay\Relay;
2019
use Symfony\Component\Cache\Adapter\AbstractAdapter;
2120

@@ -73,7 +72,7 @@ public static function createHandler(object|string $connection, array $options =
7372
}
7473
$connection[3] = '-';
7574
$params = class_exists(DsnParser::class) ? (new DsnParser())->parse($connection) : ['url' => $connection];
76-
$config = class_exists(ORMSetup::class) ? ORMSetup::createConfiguration(true) : new Configuration();
75+
$config = new Configuration();
7776
if (class_exists(DefaultSchemaManagerFactory::class)) {
7877
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
7978
}

Tests/RequestTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,9 @@ public function testGetPayload()
13091309

13101310
$req = new Request([], ['foo' => 'bar'], [], [], [], [], json_encode(['baz' => 'qux']));
13111311
$this->assertSame(['foo' => 'bar'], $req->getPayload()->all());
1312+
1313+
$req = new Request([], [], [], [], [], [], '');
1314+
$this->assertSame([], $req->getPayload()->all());
13121315
}
13131316

13141317
/**

0 commit comments

Comments
 (0)