From b3cf36af9e1b71c8924ad1c9f8784d6a3bf6d26b Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Mon, 6 Aug 2012 16:02:40 +0200 Subject: [PATCH 1/9] [Config] Missing type argument passed to loader. In FileLoader the $type is not passed to the child loader. --- src/Symfony/Component/Config/Loader/FileLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Config/Loader/FileLoader.php b/src/Symfony/Component/Config/Loader/FileLoader.php index 39c36b465f..15a1f7b543 100644 --- a/src/Symfony/Component/Config/Loader/FileLoader.php +++ b/src/Symfony/Component/Config/Loader/FileLoader.php @@ -72,7 +72,7 @@ abstract class FileLoader extends Loader } self::$loading[$resource] = true; - $ret = $loader->load($resource); + $ret = $loader->load($resource, $type); unset(self::$loading[$resource]); From 2a124bc89c0ba32b19851c59549d8be307fb4569 Mon Sep 17 00:00:00 2001 From: hidenorigoto Date: Tue, 7 Aug 2012 00:59:43 +0900 Subject: [PATCH 2/9] [DependencyInjection] Added a test for a frozen constructor of a container with no parameters --- .../Dumper/PhpDumperTest.php | 14 ++++++ .../Fixtures/php/services11.php | 45 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 tests/Symfony/Tests/Component/DependencyInjection/Fixtures/php/services11.php diff --git a/tests/Symfony/Tests/Component/DependencyInjection/Dumper/PhpDumperTest.php b/tests/Symfony/Tests/Component/DependencyInjection/Dumper/PhpDumperTest.php index 221a007541..ed2228a523 100644 --- a/tests/Symfony/Tests/Component/DependencyInjection/Dumper/PhpDumperTest.php +++ b/tests/Symfony/Tests/Component/DependencyInjection/Dumper/PhpDumperTest.php @@ -37,6 +37,20 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase new PhpDumper($container); } + public function testDumpFrozenContainerWithNoParameter() + { + $container = new ContainerBuilder(); + $container->register('foo', 'stdClass'); + + $container->compile(); + + $dumper = new PhpDumper($container); + + $dumpedString = $dumper->dump(); + $this->assertStringEqualsFile(self::$fixturesPath.'/php/services11.php', $dumpedString, '->dump() does not add getDefaultParameters() method call if container have no parameters.'); + $this->assertNotRegexp("/function getDefaultParameters\(/", $dumpedString, '->dump() does not add getDefaultParameters() method definition.'); + } + public function testDumpOptimizationString() { $definition = new Definition(); diff --git a/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/php/services11.php b/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/php/services11.php new file mode 100644 index 0000000000..65c71e1391 --- /dev/null +++ b/tests/Symfony/Tests/Component/DependencyInjection/Fixtures/php/services11.php @@ -0,0 +1,45 @@ +services = + $this->scopedServices = + $this->scopeStacks = array(); + + $this->set('service_container', $this); + + $this->scopes = array(); + $this->scopeChildren = array(); + } + + /** + * Gets the 'foo' service. + * + * This service is shared. + * This method always returns the same instance of the service. + * + * @return stdClass A stdClass instance. + */ + protected function getFooService() + { + return $this->services['foo'] = new \stdClass(); + } +} From 1a4a4ee93ce6d05b523926650e6d51d6d8cd38b6 Mon Sep 17 00:00:00 2001 From: hidenorigoto Date: Tue, 7 Aug 2012 01:00:34 +0900 Subject: [PATCH 3/9] [DependencyInjection] Fixed a frozen constructor of a container with no parameters --- .../Component/DependencyInjection/Dumper/PhpDumper.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 222355171d..b50974b267 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -689,7 +689,13 @@ EOF; */ public function __construct() { - \$this->parameters = \$this->getDefaultParameters(); +EOF; + + if ($this->container->getParameterBag()->all()) { + $code .= "\n \$this->parameters = \$this->getDefaultParameters();\n"; + } + + $code .= <<services = \$this->scopedServices = From c51fc105f4d9a3afa29abe1430d68a1b04c8a9f2 Mon Sep 17 00:00:00 2001 From: Kris Wallsmith Date: Tue, 7 Aug 2012 14:21:04 -0400 Subject: [PATCH 4/9] avoid fatal error on invalid session --- .../Http/Firewall/ContextListener.php | 31 ++++++---- .../Http/Firewall/ContextListenerTest.php | 61 +++++++++++++++++++ 2 files changed, 80 insertions(+), 12 deletions(-) create mode 100644 tests/Symfony/Tests/Component/Security/Http/Firewall/ContextListenerTest.php diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php index 52dea564ec..1ef59957cc 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php @@ -66,19 +66,26 @@ class ContextListener implements ListenerInterface if (null === $session || null === $token = $session->get('_security_'.$this->contextKey)) { $this->context->setToken(null); - } else { - if (null !== $this->logger) { - $this->logger->debug('Read SecurityContext from the session'); - } - - $token = unserialize($token); - - if (null !== $token) { - $token = $this->refreshUser($token); - } - - $this->context->setToken($token); + return; } + + $token = unserialize($token); + + if (null !== $this->logger) { + $this->logger->debug('Read SecurityContext from the session'); + } + + if ($token instanceof TokenInterface) { + $token = $this->refreshUser($token); + } elseif (null !== $token) { + if (null !== $this->logger) { + $this->logger->warn(sprintf('Session includes a "%s" where a security token is expected', is_object($value) ? get_class($value) : gettype($value))); + } + + $token = null; + } + + $this->context->setToken($token); } /** diff --git a/tests/Symfony/Tests/Component/Security/Http/Firewall/ContextListenerTest.php b/tests/Symfony/Tests/Component/Security/Http/Firewall/ContextListenerTest.php new file mode 100644 index 0000000000..040f3a8c61 --- /dev/null +++ b/tests/Symfony/Tests/Component/Security/Http/Firewall/ContextListenerTest.php @@ -0,0 +1,61 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Symfony\Tests\Component\Security\Http\Firewall; + +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Security\Http\Firewall\ContextListener; + +class ContextListenerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider provideInvalidToken + */ + public function testInvalidTokenInSession($token) + { + $context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'); + $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') + ->disableOriginalConstructor() + ->getMock(); + $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session') + ->disableOriginalConstructor() + ->getMock(); + + $event->expects($this->any()) + ->method('getRequest') + ->will($this->returnValue($request)); + $request->expects($this->any()) + ->method('hasPreviousSession') + ->will($this->returnValue(true)); + $request->expects($this->any()) + ->method('getSession') + ->will($this->returnValue($session)); + $session->expects($this->any()) + ->method('get') + ->with('_security_key123') + ->will($this->returnValue(serialize($token))); + $context->expects($this->once()) + ->method('setToken') + ->with(null); + + $listener = new ContextListener($context, array(), 'key123'); + $listener->handle($event); + } + + public function provideInvalidToken() + { + return array( + array(new \__PHP_Incomplete_Class()), + array(null), + ); + } +} From 832f8dd4fe699b0086cc97063b899b8dd69cfa4f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 18 Aug 2012 19:41:54 +0200 Subject: [PATCH 5/9] Add support for Monolog 1.2.0 --- src/Symfony/Bridge/Monolog/Handler/DebugHandler.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Monolog/Handler/DebugHandler.php b/src/Symfony/Bridge/Monolog/Handler/DebugHandler.php index e1c1f512b2..96b7fdd073 100644 --- a/src/Symfony/Bridge/Monolog/Handler/DebugHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/DebugHandler.php @@ -47,7 +47,11 @@ class DebugHandler extends TestHandler implements DebugLoggerInterface public function countErrors() { $cnt = 0; - foreach (array(Logger::ERROR, Logger::CRITICAL, Logger::ALERT) as $level) { + $levels = array(Logger::ERROR, Logger::CRITICAL, Logger::ALERT); + if (defined('Monolog\Logger::EMERGENCY')) { + $levels[] = Logger::EMERGENCY; + } + foreach ($levels as $level) { if (isset($this->recordsByLevel[$level])) { $cnt += count($this->recordsByLevel[$level]); } From e49afde2ee7a520ab81436fb4b57c2fd8b128f1f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 19 Aug 2012 09:57:44 +0200 Subject: [PATCH 6/9] Update monolog compatibility --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e0f296ceb5..41bed9d02e 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=5.3.2", "doctrine/common": ">=2.1,<2.3-dev", - "monolog/monolog": ">=1.0,<1.2-dev", + "monolog/monolog": ">=1.0,<1.3-dev", "swiftmailer/swiftmailer": "4.2.*", "twig/twig": ">=1.1,<2.0-dev" }, From 9beffff263ebc942c77d3e259b8bc582fb325da8 Mon Sep 17 00:00:00 2001 From: Christophe L Date: Sat, 25 Aug 2012 22:46:45 +0400 Subject: [PATCH 7/9] [HttpKernel] KernelTest::testGetRootDir fails on Windows for branch 2.0 --- tests/Symfony/Tests/Component/HttpKernel/KernelTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Symfony/Tests/Component/HttpKernel/KernelTest.php b/tests/Symfony/Tests/Component/HttpKernel/KernelTest.php index 2572044b43..7aba5c360e 100644 --- a/tests/Symfony/Tests/Component/HttpKernel/KernelTest.php +++ b/tests/Symfony/Tests/Component/HttpKernel/KernelTest.php @@ -284,7 +284,7 @@ EOF; { $kernel = new KernelForTest('test', true); - $this->assertEquals(__DIR__, $kernel->getRootDir()); + $this->assertEquals(__DIR__, realpath($kernel->getRootDir())); } public function testGetName() From f694615bc517feb632ca4d044bf8efd829a4727e Mon Sep 17 00:00:00 2001 From: Christophe L Date: Sat, 25 Aug 2012 23:29:32 +0400 Subject: [PATCH 8/9] [Process] fix ProcessTest::testProcessPipes hangs on Windows on branch 2.0 --- tests/Symfony/Tests/Component/Process/ProcessTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Symfony/Tests/Component/Process/ProcessTest.php b/tests/Symfony/Tests/Component/Process/ProcessTest.php index 2bc746c461..fba1eafd9d 100644 --- a/tests/Symfony/Tests/Component/Process/ProcessTest.php +++ b/tests/Symfony/Tests/Component/Process/ProcessTest.php @@ -55,8 +55,8 @@ class ProcessTest extends \PHPUnit_Framework_TestCase */ public function testProcessPipes($expected, $code) { - if (strpos(PHP_OS, "WIN") === 0 && version_compare(phpversion(), "5.3.9", "<")) { - $this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 fixed in http://svn.php.net/viewvc?view=revision&revision=318366'); + if (strpos(PHP_OS, "WIN") === 0) { + $this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 and https://bugs.php.net/bug.php?id=51800'); } $p = new Process(sprintf('php -r %s', escapeshellarg($code))); From 9a355e995a1584808702db434fe09de40195422e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 26 Aug 2012 11:23:03 +0200 Subject: [PATCH 9/9] [HttpKernel] excluded a test on PHP 5.3.16, which is buggy (PHP, not Symfony ;)) --- .../Controller/ControllerResolverTest.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/Symfony/Tests/Component/HttpKernel/Controller/ControllerResolverTest.php b/tests/Symfony/Tests/Component/HttpKernel/Controller/ControllerResolverTest.php index b263a37e56..c3edf81e1d 100644 --- a/tests/Symfony/Tests/Component/HttpKernel/Controller/ControllerResolverTest.php +++ b/tests/Symfony/Tests/Component/HttpKernel/Controller/ControllerResolverTest.php @@ -119,11 +119,15 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase $request->attributes->set('foobar', 'foobar'); $controller = array(new self(), 'controllerMethod3'); - try { - $resolver->getArguments($request, $controller); - $this->fail('->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); + if (version_compare(PHP_VERSION, '5.3.16', '==')) { + $this->markTestSkipped('PHP 5.3.16 has a major bug in the Reflection sub-system'); + } else { + try { + $resolver->getArguments($request, $controller); + $this->fail('->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); + } catch (\Exception $e) { + $this->assertInstanceOf('\RuntimeException', $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value'); + } } $request = Request::create('/');