Loading composer.lock +6 −5 Original line number Diff line number Diff line Loading @@ -528,7 +528,7 @@ "dist": { "type": "path", "url": "core", "reference": "02fb64caa7f852779c5ba9b94d7b48755612d45d" "reference": "365584bd91d9f305a9bf0db5a9acecf55c22ba57" }, "require": { "asm89/stack-cors": "^1.1", Loading Loading @@ -751,6 +751,7 @@ "lib/Drupal/Core/DependencyInjection/Container.php", "lib/Drupal/Core/DrupalKernel.php", "lib/Drupal/Core/DrupalKernelInterface.php", "lib/Drupal/Core/Http/InputBag.php", "lib/Drupal/Core/Installer/InstallerRedirectTrait.php", "lib/Drupal/Core/Site/Settings.php" ], Loading Loading @@ -7811,12 +7812,12 @@ "version": "1.9.1", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", "url": "https://github.com/webmozarts/assert.git", "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", "url": "https://api.github.com/repos/webmozarts/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", "shasum": "" }, Loading Loading @@ -7854,8 +7855,8 @@ "validate" ], "support": { "issues": "https://github.com/webmozart/assert/issues", "source": "https://github.com/webmozart/assert/tree/master" "issues": "https://github.com/webmozarts/assert/issues", "source": "https://github.com/webmozarts/assert/tree/1.9.1" }, "time": "2020-07-08T17:02:28+00:00" } Loading core/composer.json +1 −0 Original line number Diff line number Diff line Loading @@ -196,6 +196,7 @@ "lib/Drupal/Core/DependencyInjection/Container.php", "lib/Drupal/Core/DrupalKernel.php", "lib/Drupal/Core/DrupalKernelInterface.php", "lib/Drupal/Core/Http/InputBag.php", "lib/Drupal/Core/Installer/InstallerRedirectTrait.php", "lib/Drupal/Core/Site/Settings.php" ], Loading core/lib/Drupal/Core/DrupalKernel.php +10 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ use Drupal\Core\DependencyInjection\YamlFileLoader; use Drupal\Core\Extension\ExtensionDiscovery; use Drupal\Core\File\MimeType\MimeTypeGuesser; use Drupal\Core\Http\InputBag; use Drupal\Core\Http\TrustedHostsRequestFactory; use Drupal\Core\Installer\InstallerKernel; use Drupal\Core\Installer\InstallerRedirectTrait; Loading @@ -33,6 +34,7 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; use Symfony\Component\HttpKernel\TerminableInterface; use Symfony\Component\HttpFoundation\InputBag as SymfonyInputBag; use TYPO3\PharStreamWrapper\Manager as PharStreamWrapperManager; use TYPO3\PharStreamWrapper\Behavior as PharStreamWrapperBehavior; use TYPO3\PharStreamWrapper\PharStreamWrapper; Loading Loading @@ -692,6 +694,14 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = // Ensure sane PHP environment variables. static::bootEnvironment(); // Replace ParameterBag with InputBag for compatibility with Symfony 5. // @todo Remove this when Symfony 4 is no longer supported. foreach (['request', 'query', 'cookies'] as $bag) { if (!($bag instanceof SymfonyInputBag)) { $request->$bag = new InputBag($request->$bag->all()); } } try { $this->initializeSettings($request); Loading core/lib/Drupal/Core/Http/InputBag.php 0 → 100644 +37 −0 Original line number Diff line number Diff line <?php namespace Drupal\Core\Http; use Symfony\Component\HttpFoundation\ParameterBag; /** * Forward compatibility class for Symfony 5. * * @internal only used as a bridge from Symfony 4 to Symfony 5, will be removed * in drupal:10.0.0. */ final class InputBag extends ParameterBag { /** * Returns the parameters. * * @param string|null $key * The name of the parameter to return or null to get them all. * * @return array * An array of parameters. */ public function all(string $key = NULL): array { if ($key === NULL) { return $this->parameters; } $value = $this->parameters[$key] ?? []; if (!is_array($value)) { throw new \UnexpectedValueException(sprintf('Unexpected value for parameter "%s": expecting "array", got "%s".', $key, get_debug_type($value))); } return $value; } } core/tests/Drupal/Tests/Core/Http/InputBagTest.php 0 → 100644 +31 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\Core\Http; use Drupal\Core\Http\InputBag; use Drupal\Tests\UnitTestCase; /** * @coversDefaultClass \Drupal\Core\Http\InputBag * * @group Http */ class InputBagTest extends UnitTestCase { /** * @covers ::all */ public function testAll() { $input = [ 'bad' => 'bad', 'good' => ['good'], ]; $input_bag = new InputBag(); $input_bag->replace($input); $this->assertSame($input_bag->all(), $input); $this->assertSame($input_bag->all('good'), ['good']); $this->expectException(\UnexpectedValueException::class); $input_bag->all('bad'); } } Loading
composer.lock +6 −5 Original line number Diff line number Diff line Loading @@ -528,7 +528,7 @@ "dist": { "type": "path", "url": "core", "reference": "02fb64caa7f852779c5ba9b94d7b48755612d45d" "reference": "365584bd91d9f305a9bf0db5a9acecf55c22ba57" }, "require": { "asm89/stack-cors": "^1.1", Loading Loading @@ -751,6 +751,7 @@ "lib/Drupal/Core/DependencyInjection/Container.php", "lib/Drupal/Core/DrupalKernel.php", "lib/Drupal/Core/DrupalKernelInterface.php", "lib/Drupal/Core/Http/InputBag.php", "lib/Drupal/Core/Installer/InstallerRedirectTrait.php", "lib/Drupal/Core/Site/Settings.php" ], Loading Loading @@ -7811,12 +7812,12 @@ "version": "1.9.1", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", "url": "https://github.com/webmozarts/assert.git", "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", "url": "https://api.github.com/repos/webmozarts/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", "shasum": "" }, Loading Loading @@ -7854,8 +7855,8 @@ "validate" ], "support": { "issues": "https://github.com/webmozart/assert/issues", "source": "https://github.com/webmozart/assert/tree/master" "issues": "https://github.com/webmozarts/assert/issues", "source": "https://github.com/webmozarts/assert/tree/1.9.1" }, "time": "2020-07-08T17:02:28+00:00" } Loading
core/composer.json +1 −0 Original line number Diff line number Diff line Loading @@ -196,6 +196,7 @@ "lib/Drupal/Core/DependencyInjection/Container.php", "lib/Drupal/Core/DrupalKernel.php", "lib/Drupal/Core/DrupalKernelInterface.php", "lib/Drupal/Core/Http/InputBag.php", "lib/Drupal/Core/Installer/InstallerRedirectTrait.php", "lib/Drupal/Core/Site/Settings.php" ], Loading
core/lib/Drupal/Core/DrupalKernel.php +10 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ use Drupal\Core\DependencyInjection\YamlFileLoader; use Drupal\Core\Extension\ExtensionDiscovery; use Drupal\Core\File\MimeType\MimeTypeGuesser; use Drupal\Core\Http\InputBag; use Drupal\Core\Http\TrustedHostsRequestFactory; use Drupal\Core\Installer\InstallerKernel; use Drupal\Core\Installer\InstallerRedirectTrait; Loading @@ -33,6 +34,7 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; use Symfony\Component\HttpKernel\TerminableInterface; use Symfony\Component\HttpFoundation\InputBag as SymfonyInputBag; use TYPO3\PharStreamWrapper\Manager as PharStreamWrapperManager; use TYPO3\PharStreamWrapper\Behavior as PharStreamWrapperBehavior; use TYPO3\PharStreamWrapper\PharStreamWrapper; Loading Loading @@ -692,6 +694,14 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = // Ensure sane PHP environment variables. static::bootEnvironment(); // Replace ParameterBag with InputBag for compatibility with Symfony 5. // @todo Remove this when Symfony 4 is no longer supported. foreach (['request', 'query', 'cookies'] as $bag) { if (!($bag instanceof SymfonyInputBag)) { $request->$bag = new InputBag($request->$bag->all()); } } try { $this->initializeSettings($request); Loading
core/lib/Drupal/Core/Http/InputBag.php 0 → 100644 +37 −0 Original line number Diff line number Diff line <?php namespace Drupal\Core\Http; use Symfony\Component\HttpFoundation\ParameterBag; /** * Forward compatibility class for Symfony 5. * * @internal only used as a bridge from Symfony 4 to Symfony 5, will be removed * in drupal:10.0.0. */ final class InputBag extends ParameterBag { /** * Returns the parameters. * * @param string|null $key * The name of the parameter to return or null to get them all. * * @return array * An array of parameters. */ public function all(string $key = NULL): array { if ($key === NULL) { return $this->parameters; } $value = $this->parameters[$key] ?? []; if (!is_array($value)) { throw new \UnexpectedValueException(sprintf('Unexpected value for parameter "%s": expecting "array", got "%s".', $key, get_debug_type($value))); } return $value; } }
core/tests/Drupal/Tests/Core/Http/InputBagTest.php 0 → 100644 +31 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\Core\Http; use Drupal\Core\Http\InputBag; use Drupal\Tests\UnitTestCase; /** * @coversDefaultClass \Drupal\Core\Http\InputBag * * @group Http */ class InputBagTest extends UnitTestCase { /** * @covers ::all */ public function testAll() { $input = [ 'bad' => 'bad', 'good' => ['good'], ]; $input_bag = new InputBag(); $input_bag->replace($input); $this->assertSame($input_bag->all(), $input); $this->assertSame($input_bag->all('good'), ['good']); $this->expectException(\UnexpectedValueException::class); $input_bag->all('bad'); } }