From 863f63205415ee9add06ee50f2984194a9f77b91 Mon Sep 17 00:00:00 2001 From: Amrouche Hamza Date: Wed, 6 Dec 2017 13:44:17 +0100 Subject: [PATCH 01/13] [Console] Commands with an alias should not be recognized as ambiguous --- src/Symfony/Component/Console/Application.php | 9 ++++---- .../Console/Tests/ApplicationTest.php | 10 +++++++++ .../Console/Tests/Fixtures/TestTiti.php | 21 ++++++++++++++++++ .../Console/Tests/Fixtures/TestToto.php | 22 +++++++++++++++++++ 4 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/TestTiti.php create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/TestToto.php diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 6ab9f011ac..53460d2de2 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -498,7 +498,7 @@ class Application public function find($name) { $this->init(); - + $aliases = array(); $allCommands = array_keys($this->commands); $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $name); $commands = preg_grep('{^'.$expr.'}', $allCommands); @@ -526,15 +526,16 @@ class Application // filter out aliases for commands which are already on the list if (count($commands) > 1) { $commandList = $this->commands; - $commands = array_filter($commands, function ($nameOrAlias) use ($commandList, $commands) { + $commands = array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) { $commandName = $commandList[$nameOrAlias]->getName(); + $aliases[$nameOrAlias] = $commandName; return $commandName === $nameOrAlias || !in_array($commandName, $commands); }); } - $exact = in_array($name, $commands, true); - if (count($commands) > 1 && !$exact) { + $exact = in_array($name, $commands, true) || isset($aliases[$name]); + if (!$exact && count($commands) > 1) { $suggestions = $this->getAbbreviationSuggestions(array_values($commands)); throw new \InvalidArgumentException(sprintf('Command "%s" is ambiguous (%s).', $name, $suggestions)); diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 8ffc5d6951..5ab3b0a598 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -49,6 +49,8 @@ class ApplicationTest extends TestCase require_once self::$fixturesPath.'/BarBucCommand.php'; require_once self::$fixturesPath.'/FooSubnamespaced1Command.php'; require_once self::$fixturesPath.'/FooSubnamespaced2Command.php'; + require_once self::$fixturesPath.'/TestTiti.php'; + require_once self::$fixturesPath.'/TestToto.php'; } protected function normalizeLineBreaks($text) @@ -226,6 +228,14 @@ class ApplicationTest extends TestCase $application->findNamespace('f'); } + public function testFindNonAmbiguous() + { + $application = new Application(); + $application->add(new \TestTiti()); + $application->add(new \TestToto()); + $this->assertEquals('test-toto', $application->find('test')->getName()); + } + /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage There are no commands defined in the "bar" namespace. diff --git a/src/Symfony/Component/Console/Tests/Fixtures/TestTiti.php b/src/Symfony/Component/Console/Tests/Fixtures/TestTiti.php new file mode 100644 index 0000000000..72e29d2a0a --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/TestTiti.php @@ -0,0 +1,21 @@ +setName('test-titi') + ->setDescription('The test:titi command') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $output->write('test-titi'); + } +} diff --git a/src/Symfony/Component/Console/Tests/Fixtures/TestToto.php b/src/Symfony/Component/Console/Tests/Fixtures/TestToto.php new file mode 100644 index 0000000000..f14805db68 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/TestToto.php @@ -0,0 +1,22 @@ +setName('test-toto') + ->setDescription('The test-toto command') + ->setAliases(array('test')) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $output->write('test-toto'); + } +} From bfeee1f0114e31e28fab0fbb19e5f0c9e81d1d59 Mon Sep 17 00:00:00 2001 From: Amrouche Hamza Date: Sat, 16 Dec 2017 17:37:44 +0100 Subject: [PATCH 02/13] [WebServerBundle] fix a bug where require would not require the good file because of env --- src/Symfony/Bundle/WebServerBundle/Resources/router.php | 2 +- src/Symfony/Bundle/WebServerBundle/WebServer.php | 2 +- src/Symfony/Bundle/WebServerBundle/WebServerConfig.php | 2 +- src/Symfony/Bundle/WebServerBundle/composer.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/WebServerBundle/Resources/router.php b/src/Symfony/Bundle/WebServerBundle/Resources/router.php index 187be0b836..a366b381aa 100644 --- a/src/Symfony/Bundle/WebServerBundle/Resources/router.php +++ b/src/Symfony/Bundle/WebServerBundle/Resources/router.php @@ -30,7 +30,7 @@ if (is_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.$_SERVER['SCRIPT_NAME' return false; } -$script = getenv('APP_FRONT_CONTROLLER') ?: 'index.php'; +$script = isset($_ENV['APP_FRONT_CONTROLLER']) ? $_ENV['APP_FRONT_CONTROLLER'] : 'index.php'; $_SERVER = array_merge($_SERVER, $_ENV); $_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.$script; diff --git a/src/Symfony/Bundle/WebServerBundle/WebServer.php b/src/Symfony/Bundle/WebServerBundle/WebServer.php index e3425ec8bb..4e5c001849 100644 --- a/src/Symfony/Bundle/WebServerBundle/WebServer.php +++ b/src/Symfony/Bundle/WebServerBundle/WebServer.php @@ -150,7 +150,7 @@ class WebServer throw new \RuntimeException('Unable to find the PHP binary.'); } - $process = new Process(array($binary, '-S', $config->getAddress(), $config->getRouter())); + $process = new Process(array($binary, '-dvariables_order=EGPCS', '-S', $config->getAddress(), $config->getRouter())); $process->setWorkingDirectory($config->getDocumentRoot()); $process->setTimeout(null); diff --git a/src/Symfony/Bundle/WebServerBundle/WebServerConfig.php b/src/Symfony/Bundle/WebServerBundle/WebServerConfig.php index 88ed375dd1..2615f16119 100644 --- a/src/Symfony/Bundle/WebServerBundle/WebServerConfig.php +++ b/src/Symfony/Bundle/WebServerBundle/WebServerConfig.php @@ -32,7 +32,7 @@ class WebServerConfig throw new \InvalidArgumentException(sprintf('Unable to find the front controller under "%s" (none of these files exist: %s).', $documentRoot, implode(', ', $this->getFrontControllerFileNames($env)))); } - putenv('APP_FRONT_CONTROLLER='.$file); + $_ENV['APP_FRONT_CONTROLLER'] = $file; $this->documentRoot = $documentRoot; $this->env = $env; diff --git a/src/Symfony/Bundle/WebServerBundle/composer.json b/src/Symfony/Bundle/WebServerBundle/composer.json index c48607bca4..471e4f87bf 100644 --- a/src/Symfony/Bundle/WebServerBundle/composer.json +++ b/src/Symfony/Bundle/WebServerBundle/composer.json @@ -19,7 +19,7 @@ "php": "^5.5.9|>=7.0.8", "symfony/console": "~3.3", "symfony/http-kernel": "~3.3", - "symfony/process": "~3.3" + "symfony/process": "~3.3.14" }, "autoload": { "psr-4": { "Symfony\\Bundle\\WebServerBundle\\": "" }, From 0d4bce66763c58b74abf46d0278e63329768a6ef Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 20 Dec 2017 12:18:49 +0100 Subject: [PATCH 03/13] [Process] Dont use getenv(), it returns arrays and can introduce subtle breaks accros PHP versions --- src/Symfony/Component/Process/Process.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 4087dabc14..4bebbb4d9a 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -1718,15 +1718,11 @@ class Process implements \IteratorAggregate private function getDefaultEnv() { - if (\PHP_VERSION_ID >= 70100) { - $env = getenv(); - } else { - $env = array(); + $env = array(); - foreach ($_SERVER as $k => $v) { - if (is_string($v) && false !== $v = getenv($k)) { - $env[$k] = $v; - } + foreach ($_SERVER as $k => $v) { + if (is_string($v) && false !== $v = getenv($k)) { + $env[$k] = $v; } } From 03adce239d330b723e8beaec604019aadd08f280 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 20 Dec 2017 16:25:04 +0100 Subject: [PATCH 04/13] [Process] Fix setting empty env vars --- src/Symfony/Component/Process/Process.php | 10 +++++++++- src/Symfony/Component/Process/Tests/ProcessTest.php | 6 +++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 4bebbb4d9a..d7c5a61b16 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -326,8 +326,16 @@ class Process implements \IteratorAggregate // @see : https://bugs.php.net/69442 $ptsWorkaround = fopen(__FILE__, 'r'); } + if (defined('HHVM_VERSION')) { + $envPairs = $env; + } else { + $envPairs = array(); + foreach ($env as $k => $v) { + $envPairs[] = $k.'='.$v; + } + } - $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $env, $this->options); + $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options); if (!is_resource($this->process)) { throw new RuntimeException('Unable to launch a new process.'); diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index c927da6471..16e57d3763 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -1423,14 +1423,14 @@ class ProcessTest extends TestCase public function testEnvIsInherited() { - $process = $this->getProcessForCode('echo serialize($_SERVER);', null, array('BAR' => 'BAZ')); + $process = $this->getProcessForCode('echo serialize($_SERVER);', null, array('BAR' => 'BAZ', 'EMPTY' => '')); putenv('FOO=BAR'); $_ENV['FOO'] = 'BAR'; $process->run(); - $expected = array('BAR' => 'BAZ', 'FOO' => 'BAR'); + $expected = array('BAR' => 'BAZ', 'EMPTY' => '', 'FOO' => 'BAR'); $env = array_intersect_key(unserialize($process->getOutput()), $expected); $this->assertEquals($expected, $env); @@ -1511,7 +1511,7 @@ Array ) EOTXT; - $this->assertSame($expected, $p->getOutput()); + $this->assertSame($expected, str_replace('Standard input code', '-', $p->getOutput())); } public function provideEscapeArgument() From c84c9284407db48423c37a49a62ee6dcefb10eee Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 21 Dec 2017 16:17:10 +0100 Subject: [PATCH 05/13] [Bridge/PhpUnit] thank phpunit/phpunit --- src/Symfony/Bridge/PhpUnit/composer.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Bridge/PhpUnit/composer.json b/src/Symfony/Bridge/PhpUnit/composer.json index 847bb691d3..1c5d1e60af 100644 --- a/src/Symfony/Bridge/PhpUnit/composer.json +++ b/src/Symfony/Bridge/PhpUnit/composer.json @@ -41,6 +41,10 @@ "extra": { "branch-alias": { "dev-master": "3.3-dev" + }, + "thanks": { + "name": "phpunit/phpunit", + "url": "https://github.com/sebastianbergmann/phpunit" } } } From c1b770889f9c2fe22d6f4a2bf846aa599207c049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ron=20G=C3=A4hler?= Date: Fri, 22 Dec 2017 16:05:44 +0100 Subject: [PATCH 06/13] Update MemcachedTrait.php typo --- src/Symfony/Component/Cache/Traits/MemcachedTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Cache/Traits/MemcachedTrait.php b/src/Symfony/Component/Cache/Traits/MemcachedTrait.php index 2c163445a1..efb0d2d633 100644 --- a/src/Symfony/Component/Cache/Traits/MemcachedTrait.php +++ b/src/Symfony/Component/Cache/Traits/MemcachedTrait.php @@ -71,7 +71,7 @@ trait MemcachedTrait * * @return \Memcached * - * @throws \ErrorEception When invalid options or servers are provided + * @throws \ErrorException When invalid options or servers are provided */ public static function createConnection($servers, array $options = array()) { From a5bc7d649b9c519ff1445493ccaeb6e6591c267d Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Tue, 19 Dec 2017 22:44:19 +0100 Subject: [PATCH 07/13] PHP CS Fixer: use PHPUnit Migration ruleset --- .php_cs.dist | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.php_cs.dist b/.php_cs.dist index 7f8d3b03bc..27b38a4dae 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -8,9 +8,10 @@ return PhpCsFixer\Config::create() ->setRules(array( '@Symfony' => true, '@Symfony:risky' => true, + '@PHPUnit48Migration:risky' => true, + 'php_unit_no_expectation_annotation' => false, // part of `PHPUnitXYMigration:risky` ruleset, to be enabled when PHPUnit 4.x support will be dropped, as we don't want to rewrite exceptions handling twice 'array_syntax' => array('syntax' => 'long'), 'protected_to_private' => false, - 'php_unit_dedicate_assert' => array('target' => '3.5'), )) ->setRiskyAllowed(true) ->setFinder( From d4a428c20d996886c167be64c904adbaf95c3262 Mon Sep 17 00:00:00 2001 From: "Issei.M" Date: Wed, 27 Dec 2017 17:53:35 +0900 Subject: [PATCH 08/13] [Config] Fix closure CS --- src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php b/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php index 004042817a..f83f1c209b 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php @@ -161,7 +161,7 @@ class ExprBuilder */ public function thenInvalid($message) { - $this->thenPart = function ($v) use ($message) {throw new \InvalidArgumentException(sprintf($message, json_encode($v))); }; + $this->thenPart = function ($v) use ($message) { throw new \InvalidArgumentException(sprintf($message, json_encode($v))); }; return $this; } From 29486a431cb24e690dc34ee2d66d8fe031b041a0 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Thu, 28 Dec 2017 02:21:22 +0200 Subject: [PATCH 09/13] [Serializer] Correct typing mistake in DocBlock | Q | A | ------------- | --- | Branch? | 2.1 to 4.0 | Bug fix? | yes (comment only) | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | na | Fixed tickets | na | License | MIT | Doc PR | DocBlock comment referred to `NormalizableInterface` but code was using `DenormalizableInterface` --- .../Component/Serializer/Normalizer/CustomNormalizer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php index f64aa4d3e3..a470a65561 100644 --- a/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php @@ -49,7 +49,7 @@ class CustomNormalizer extends SerializerAwareNormalizer implements NormalizerIn } /** - * Checks if the given class implements the NormalizableInterface. + * Checks if the given class implements the DenormalizableInterface. * * @param mixed $data Data to denormalize from * @param string $type The class to which the data should be denormalized From f4fcbcd3da566a0359d3521fa450b69ff1399be5 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 28 Dec 2017 18:49:57 +0100 Subject: [PATCH 10/13] Error handlers' $context should be optional as it's deprecated --- src/Symfony/Component/Config/ResourceCheckerConfigCache.php | 2 +- .../HttpFoundation/Session/Storage/NativeSessionStorage.php | 2 +- src/Symfony/Component/PropertyAccess/PropertyAccessor.php | 2 +- src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Config/ResourceCheckerConfigCache.php b/src/Symfony/Component/Config/ResourceCheckerConfigCache.php index b3471e5d75..0394836ae8 100644 --- a/src/Symfony/Component/Config/ResourceCheckerConfigCache.php +++ b/src/Symfony/Component/Config/ResourceCheckerConfigCache.php @@ -82,7 +82,7 @@ class ResourceCheckerConfigCache implements ConfigCacheInterface $time = filemtime($this->file); $signalingException = new \UnexpectedValueException(); $prevUnserializeHandler = ini_set('unserialize_callback_func', ''); - $prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context) use (&$prevErrorHandler, $signalingException) { + $prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = array()) use (&$prevErrorHandler, $signalingException) { if (E_WARNING === $type && 'Class __PHP_Incomplete_Class has no unserializer' === $msg) { throw $signalingException; } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index 5620aae3cd..3d8c9bc064 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -221,7 +221,7 @@ class NativeSessionStorage implements SessionStorageInterface public function save() { // Register custom error handler to catch a possible failure warning during session write - set_error_handler(function ($errno, $errstr, $errfile, $errline, $errcontext) { + set_error_handler(function ($errno, $errstr, $errfile, $errline, $errcontext = array()) { throw new ContextErrorException($errstr, $errno, E_WARNING, $errfile, $errline, $errcontext); }, E_WARNING); diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index c23229dd86..d0db3946e4 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -245,7 +245,7 @@ class PropertyAccessor implements PropertyAccessorInterface /** * @internal */ - public static function handleError($type, $message, $file, $line, $context) + public static function handleError($type, $message, $file, $line, $context = array()) { if (E_RECOVERABLE_ERROR === $type) { self::throwInvalidArgumentException($message, debug_backtrace(false), 1); diff --git a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php index 8fd192d0e4..0e108f0756 100644 --- a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php @@ -195,7 +195,7 @@ abstract class AbstractCloner implements ClonerInterface */ public function cloneVar($var, $filter = 0) { - $this->prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context) { + $this->prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = array()) { if (E_RECOVERABLE_ERROR === $type || E_USER_ERROR === $type) { // Cloner never dies throw new \ErrorException($msg, 0, $type, $file, $line); From 6629ae535d88c6b974853b9bb54f19442545c3a5 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 29 Dec 2017 12:04:53 +0100 Subject: [PATCH 11/13] [WebServerBundle] Fix escaping of php binary with arguments --- src/Symfony/Bundle/WebServerBundle/WebServer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/WebServerBundle/WebServer.php b/src/Symfony/Bundle/WebServerBundle/WebServer.php index 4e5c001849..beb5190b72 100644 --- a/src/Symfony/Bundle/WebServerBundle/WebServer.php +++ b/src/Symfony/Bundle/WebServerBundle/WebServer.php @@ -146,11 +146,11 @@ class WebServer private function createServerProcess(WebServerConfig $config) { $finder = new PhpExecutableFinder(); - if (false === $binary = $finder->find()) { + if (false === $binary = $finder->find(false)) { throw new \RuntimeException('Unable to find the PHP binary.'); } - $process = new Process(array($binary, '-dvariables_order=EGPCS', '-S', $config->getAddress(), $config->getRouter())); + $process = new Process(array_merge(array($binary), $finder->findArguments(), array('-dvariables_order=EGPCS', '-S', $config->getAddress(), $config->getRouter()))); $process->setWorkingDirectory($config->getDocumentRoot()); $process->setTimeout(null); From e1591bdadf9590058a1491a097069ed4f204d2c1 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 29 Dec 2017 10:49:16 +0100 Subject: [PATCH 12/13] [HttpFoundation] Fix false-positive ConflictingHeadersException --- .../HttpFoundation/Tests/RequestTest.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index 3c123656cc..dbd10293d0 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -968,6 +968,26 @@ class RequestTest extends TestCase $request->getClientIps(); } + /** + * @dataProvider getClientIpsWithConflictingHeadersProvider + */ + public function testGetClientIpsOnlyXHttpForwardedForTrusted($httpForwarded, $httpXForwardedFor) + { + $request = new Request(); + + $server = array( + 'REMOTE_ADDR' => '88.88.88.88', + 'HTTP_FORWARDED' => $httpForwarded, + 'HTTP_X_FORWARDED_FOR' => $httpXForwardedFor, + ); + + Request::setTrustedProxies(array('88.88.88.88'), Request::HEADER_X_FORWARDED_FOR); + + $request->initialize(array(), array(), array(), array(), array(), $server); + + $this->assertSame(array_reverse(explode(',', $httpXForwardedFor)), $request->getClientIps()); + } + public function getClientIpsWithConflictingHeadersProvider() { // $httpForwarded $httpXForwardedFor From 0917c4c2ae079ff92c29f5e913b058e96fd5e5b1 Mon Sep 17 00:00:00 2001 From: Vincent CHALAMON Date: Sun, 24 Dec 2017 21:43:35 +0100 Subject: [PATCH 13/13] Add application/ld+json format associated to json --- src/Symfony/Component/HttpFoundation/Request.php | 1 + src/Symfony/Component/HttpFoundation/Tests/RequestTest.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 83b62142c9..7a24f1cf85 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1876,6 +1876,7 @@ class Request 'js' => array('application/javascript', 'application/x-javascript', 'text/javascript'), 'css' => array('text/css'), 'json' => array('application/json', 'application/x-json'), + 'jsonld' => array('application/ld+json'), 'xml' => array('text/xml', 'application/xml', 'application/x-xml'), 'rdf' => array('application/rdf+xml'), 'atom' => array('application/atom+xml'), diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index ed4224c4fd..4524f8b234 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -334,6 +334,7 @@ class RequestTest extends TestCase array('js', array('application/javascript', 'application/x-javascript', 'text/javascript')), array('css', array('text/css')), array('json', array('application/json', 'application/x-json')), + array('jsonld', array('application/ld+json')), array('xml', array('text/xml', 'application/xml', 'application/x-xml')), array('rdf', array('application/rdf+xml')), array('atom', array('application/atom+xml')),