From ab9a96b77463c48e48a6708e9329bcc5415e258b Mon Sep 17 00:00:00 2001 From: Vasily Khayrulin Date: Thu, 15 Aug 2013 17:16:55 +0400 Subject: [PATCH 1/4] Fixes for hasParameterOption and getParameterOption methods of ArgvInput --- src/Symfony/Component/Console/Input/ArgvInput.php | 10 ++++++---- .../Component/Console/Tests/Input/ArgvInputTest.php | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php index 6c3267c9fd..05640a36b1 100644 --- a/src/Symfony/Component/Console/Input/ArgvInput.php +++ b/src/Symfony/Component/Console/Input/ArgvInput.php @@ -284,9 +284,11 @@ class ArgvInput extends Input { $values = (array) $values; - foreach ($this->tokens as $v) { - if (in_array($v, $values)) { - return true; + foreach ($this->tokens as $token) { + foreach ($values as $value) { + if ($token === $value || 0 === strpos($token, $value . '=')) { + return true; + } } } @@ -311,7 +313,7 @@ class ArgvInput extends Input $tokens = $this->tokens; while ($token = array_shift($tokens)) { foreach ($values as $value) { - if (0 === strpos($token, $value)) { + if ($token === $value || 0 === strpos($token, $value . '=')) { if (false !== $pos = strpos($token, '=')) { return substr($token, $pos + 1); } diff --git a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php index 532841c0b0..cd4dceb661 100644 --- a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php @@ -230,6 +230,9 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase $input = new ArgvInput(array('cli.php', 'foo')); $this->assertFalse($input->hasParameterOption('--foo'), '->hasParameterOption() returns false if the given short option is not in the raw input'); + + $input = new ArgvInput(array('cli.php', '--foo=bar')); + $this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given option with provided value is in the raw input'); } /** @@ -248,6 +251,7 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase array(array('app/console', 'foo:bar', '--env=dev'), '--env', 'dev'), array(array('app/console', 'foo:bar', '-e', 'dev'), array('-e', '--env'), 'dev'), array(array('app/console', 'foo:bar', '--env=dev'), array('-e', '--env'), 'dev'), + array(array('app/console', 'foo:bar', '--env=dev', '--en=1'), array('--en'), '1'), ); } } From bd4488b5c8bc28cc5d73a000e1c0edf2a465b461 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 17 Aug 2013 18:29:09 +0200 Subject: [PATCH 2/4] fixed CS --- src/Symfony/Component/Console/Input/ArgvInput.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php index 05640a36b1..80bf1519bb 100644 --- a/src/Symfony/Component/Console/Input/ArgvInput.php +++ b/src/Symfony/Component/Console/Input/ArgvInput.php @@ -286,7 +286,7 @@ class ArgvInput extends Input foreach ($this->tokens as $token) { foreach ($values as $value) { - if ($token === $value || 0 === strpos($token, $value . '=')) { + if ($token === $value || 0 === strpos($token, $value.'=')) { return true; } } @@ -313,7 +313,7 @@ class ArgvInput extends Input $tokens = $this->tokens; while ($token = array_shift($tokens)) { foreach ($values as $value) { - if ($token === $value || 0 === strpos($token, $value . '=')) { + if ($token === $value || 0 === strpos($token, $value.'=')) { if (false !== $pos = strpos($token, '=')) { return substr($token, $pos + 1); } From 99adcf1f6acdcb8ccfda98b74b8ef55f177087e7 Mon Sep 17 00:00:00 2001 From: Tom Avery Date: Fri, 16 Aug 2013 15:52:21 -0400 Subject: [PATCH 3/4] {HttpFoundation] [Session] fixed session compatibility with memcached/redis session storage Per https://bugs.php.net/bug.php?id=61470, and in fixing #7380, the following error occurs when using a Memcache or Redis session store w/ Symfony security: "Authentication exception occurred; redirecting to authentication entry point (A Token was not found in the SecurityContext.)". This patch applies the first fix only if the session store is "files" {HttpFoundation] [Session] fixed session compatibility with memcached/redis session storage Per https://bugs.php.net/bug.php?id=61470, and in fixing #7380, the following error occurs when using a Memcache or Redis session store w/ Symfony security: "Authentication exception occurred; redirecting to authentication entry point (A Token was not found in the SecurityContext.)". This patch applies the first fix only if the session store is "files" --- .../Session/Storage/NativeSessionStorage.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index ed60b9e341..ad51f3fd47 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -208,13 +208,15 @@ class NativeSessionStorage implements SessionStorageInterface $ret = session_regenerate_id($destroy); // workaround for https://bugs.php.net/bug.php?id=61470 as suggested by David Grudl - session_write_close(); - if (isset($_SESSION)) { - $backup = $_SESSION; - session_start(); - $_SESSION = $backup; - } else { - session_start(); + if($this->getSaveHandler()->getSaveHandlerName() === 'files') { + session_write_close(); + if (isset($_SESSION)) { + $backup = $_SESSION; + session_start(); + $_SESSION = $backup; + } else { + session_start(); + } } return $ret; From b46e0ad5567185f8f8c497cfa98674f4a96a03e1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 17 Aug 2013 18:32:21 +0200 Subject: [PATCH 4/4] fixed CS --- .../HttpFoundation/Session/Storage/NativeSessionStorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index ad51f3fd47..e9b7e571f4 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -208,7 +208,7 @@ class NativeSessionStorage implements SessionStorageInterface $ret = session_regenerate_id($destroy); // workaround for https://bugs.php.net/bug.php?id=61470 as suggested by David Grudl - if($this->getSaveHandler()->getSaveHandlerName() === 'files') { + if ('files' === $this->getSaveHandler()->getSaveHandlerName()) { session_write_close(); if (isset($_SESSION)) { $backup = $_SESSION;