From c6c71bf8260056c433229d1f4d00a845f82dddbd Mon Sep 17 00:00:00 2001 From: Pascal Borreli Date: Fri, 1 Mar 2013 09:15:25 +0000 Subject: [PATCH 01/26] Fixed trailing whitespace --- .../Component/Security/Resources/translations/security.fa.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Resources/translations/security.fa.xlf b/src/Symfony/Component/Security/Resources/translations/security.fa.xlf index 0824221e0a..0b76290780 100644 --- a/src/Symfony/Component/Security/Resources/translations/security.fa.xlf +++ b/src/Symfony/Component/Security/Resources/translations/security.fa.xlf @@ -20,7 +20,7 @@ Cookie has already been used by someone else. - کوکی قبلا برای شخص دیگری استفاده شده است. + کوکی قبلا برای شخص دیگری استفاده شده است. Not privileged to request the resource. From 0e7b5fb3bb928cd99efbc7ac0d41f209a7f1c6e8 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 1 Mar 2013 11:39:52 +0100 Subject: [PATCH 02/26] fixed CS --- src/Symfony/Component/HttpFoundation/Response.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 413ae36a40..08ffd4e997 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -258,7 +258,7 @@ class Response * @link http://support.microsoft.com/kb/323308 */ if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && true === $request->isSecure()) { - if(intval(preg_replace("/(MSIE )(.*?);/", "$2", $match[0])) < 9) { + if (intval(preg_replace("/(MSIE )(.*?);/", "$2", $match[0])) < 9) { $this->headers->remove('Cache-Control'); } } From 4b12118bc2d88b3ce3964ccae7f6dadfeace0f03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Simon?= Date: Fri, 1 Mar 2013 15:36:15 +0100 Subject: [PATCH 03/26] Revert "merged branch jfsimon/issue-6749 (PR #7220)" This reverts commit f52120bdd33bcc83157fc55ee088a564c727fa59, reversing changes made to 66c2be30d06bf8c9bee9e07aa57be245763c2478. --- src/Symfony/Component/Console/Input/ArgvInput.php | 1 - .../Console/Tests/Input/StringInputTest.php | 14 -------------- 2 files changed, 15 deletions(-) diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php index 2618c0691a..9addf1483d 100644 --- a/src/Symfony/Component/Console/Input/ArgvInput.php +++ b/src/Symfony/Component/Console/Input/ArgvInput.php @@ -68,7 +68,6 @@ class ArgvInput extends Input protected function setTokens(array $tokens) { $this->tokens = $tokens; - $this->parse(); } /** diff --git a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php index 4a165d4a30..031797ce74 100644 --- a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php @@ -12,8 +12,6 @@ namespace Symfony\Component\Console\Tests\Input; use Symfony\Component\Console\Input\StringInput; -use Symfony\Component\Console\Input\InputDefinition; -use Symfony\Component\Console\Input\InputOption; class StringInputTest extends \PHPUnit_Framework_TestCase { @@ -29,18 +27,6 @@ class StringInputTest extends \PHPUnit_Framework_TestCase $this->assertEquals($tokens, $p->getValue($input), $message); } - public function testInputOptionWithGivenString() - { - $definition = new InputDefinition( - array(new InputOption('foo', null, InputOption::VALUE_REQUIRED)) - ); - - $input = new StringInput('--foo=bar', $definition); - $actual = $input->getOption('foo'); - - $this->assertEquals('bar', $actual); - } - public function getTokenizeData() { return array( From f95f8e2a3b2c00ab03fbe59f01f0b4204672c367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Simon?= Date: Fri, 1 Mar 2013 15:41:03 +0100 Subject: [PATCH 04/26] [Console] added string input test --- .../Console/Tests/Input/StringInputTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php index 031797ce74..fd252c87d3 100644 --- a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Console\Tests\Input; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\StringInput; class StringInputTest extends \PHPUnit_Framework_TestCase @@ -27,6 +29,19 @@ class StringInputTest extends \PHPUnit_Framework_TestCase $this->assertEquals($tokens, $p->getValue($input), $message); } + public function testInputOptionWithGivenString() + { + $definition = new InputDefinition( + array(new InputOption('foo', null, InputOption::VALUE_REQUIRED)) + ); + + $input = new StringInput('--foo=bar'); + $input->bind($definition); + $actual = $input->getOption('foo'); + + $this->assertEquals('bar', $actual); + } + public function getTokenizeData() { return array( From 5bf2f7110f514396b46c2239fa050ad6fa265b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Simon?= Date: Fri, 1 Mar 2013 15:41:25 +0100 Subject: [PATCH 05/26] [Console] added deprecation annotation --- src/Symfony/Component/Console/Input/StringInput.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Component/Console/Input/StringInput.php b/src/Symfony/Component/Console/Input/StringInput.php index 93b1b83bb1..5a26676d3c 100644 --- a/src/Symfony/Component/Console/Input/StringInput.php +++ b/src/Symfony/Component/Console/Input/StringInput.php @@ -33,6 +33,8 @@ class StringInput extends ArgvInput * @param string $input An array of parameters from the CLI (in the argv format) * @param InputDefinition $definition A InputDefinition instance * + * @deprecated The second argument is deprecated as it does not work (will be removed in 3.0), use 'bind' method instead + * * @api */ public function __construct($input, InputDefinition $definition = null) From 32f190481a0144a6e715e16e78d58b721667422e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Simon?= Date: Fri, 1 Mar 2013 17:42:51 +0100 Subject: [PATCH 06/26] Revert "merged branch jfsimon/issue-6749 (PR #7220)" This reverts commit f52120bdd33bcc83157fc55ee088a564c727fa59, reversing changes made to 66c2be30d06bf8c9bee9e07aa57be245763c2478. --- src/Symfony/Component/Console/Input/ArgvInput.php | 1 - .../Console/Tests/Input/StringInputTest.php | 14 -------------- 2 files changed, 15 deletions(-) diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php index 2618c0691a..9addf1483d 100644 --- a/src/Symfony/Component/Console/Input/ArgvInput.php +++ b/src/Symfony/Component/Console/Input/ArgvInput.php @@ -68,7 +68,6 @@ class ArgvInput extends Input protected function setTokens(array $tokens) { $this->tokens = $tokens; - $this->parse(); } /** diff --git a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php index 4a165d4a30..031797ce74 100644 --- a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php @@ -12,8 +12,6 @@ namespace Symfony\Component\Console\Tests\Input; use Symfony\Component\Console\Input\StringInput; -use Symfony\Component\Console\Input\InputDefinition; -use Symfony\Component\Console\Input\InputOption; class StringInputTest extends \PHPUnit_Framework_TestCase { @@ -29,18 +27,6 @@ class StringInputTest extends \PHPUnit_Framework_TestCase $this->assertEquals($tokens, $p->getValue($input), $message); } - public function testInputOptionWithGivenString() - { - $definition = new InputDefinition( - array(new InputOption('foo', null, InputOption::VALUE_REQUIRED)) - ); - - $input = new StringInput('--foo=bar', $definition); - $actual = $input->getOption('foo'); - - $this->assertEquals('bar', $actual); - } - public function getTokenizeData() { return array( From 6b98883903d3bd598621f42850cb0bf8c5cde7de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Simon?= Date: Fri, 1 Mar 2013 15:41:03 +0100 Subject: [PATCH 07/26] [Console] added string input test --- .../Console/Tests/Input/StringInputTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php index 031797ce74..fd252c87d3 100644 --- a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Console\Tests\Input; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\StringInput; class StringInputTest extends \PHPUnit_Framework_TestCase @@ -27,6 +29,19 @@ class StringInputTest extends \PHPUnit_Framework_TestCase $this->assertEquals($tokens, $p->getValue($input), $message); } + public function testInputOptionWithGivenString() + { + $definition = new InputDefinition( + array(new InputOption('foo', null, InputOption::VALUE_REQUIRED)) + ); + + $input = new StringInput('--foo=bar'); + $input->bind($definition); + $actual = $input->getOption('foo'); + + $this->assertEquals('bar', $actual); + } + public function getTokenizeData() { return array( From 6681df0a12a1c882506543bd482ad423e12ed2e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Simon?= Date: Fri, 1 Mar 2013 17:50:10 +0100 Subject: [PATCH 08/26] [Console] fixed StringInput binding --- src/Symfony/Component/Console/Input/StringInput.php | 6 +++++- .../Component/Console/Tests/Input/StringInputTest.php | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Console/Input/StringInput.php b/src/Symfony/Component/Console/Input/StringInput.php index 93b1b83bb1..1bf1dc9c8e 100644 --- a/src/Symfony/Component/Console/Input/StringInput.php +++ b/src/Symfony/Component/Console/Input/StringInput.php @@ -37,9 +37,13 @@ class StringInput extends ArgvInput */ public function __construct($input, InputDefinition $definition = null) { - parent::__construct(array(), $definition); + parent::__construct(array(), null); $this->setTokens($this->tokenize($input)); + + if (null !== $definition) { + $this->bind($definition); + } } /** diff --git a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php index fd252c87d3..1ce5fe6274 100644 --- a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php @@ -35,11 +35,14 @@ class StringInputTest extends \PHPUnit_Framework_TestCase array(new InputOption('foo', null, InputOption::VALUE_REQUIRED)) ); + // call to bind $input = new StringInput('--foo=bar'); $input->bind($definition); - $actual = $input->getOption('foo'); + $this->assertEquals('bar', $input->getOption('foo')); - $this->assertEquals('bar', $actual); + // definition in constructor + $input = new StringInput('--foo=bar', $definition); + $this->assertEquals('bar', $input->getOption('foo')); } public function getTokenizeData() From acff7356ce5a49e0346960428778c5246f106ede Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Tue, 5 Mar 2013 12:07:44 +0100 Subject: [PATCH 09/26] [Routing] trigger deprecation warning for deprecated features that will be removed in 2.3 --- .../Component/Routing/RouteCollection.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Routing/RouteCollection.php b/src/Symfony/Component/Routing/RouteCollection.php index e53606da5f..ffdf57f478 100644 --- a/src/Symfony/Component/Routing/RouteCollection.php +++ b/src/Symfony/Component/Routing/RouteCollection.php @@ -65,6 +65,9 @@ class RouteCollection implements \IteratorAggregate, \Countable */ public function getParent() { + trigger_error('getParent() is deprecated since version 2.2 and will be removed in 2.3. There is no substitution ' . + 'because RouteCollection is not tree structure anymore.', E_USER_DEPRECATED); + return $this->parent; } @@ -77,6 +80,9 @@ class RouteCollection implements \IteratorAggregate, \Countable */ public function getRoot() { + trigger_error('getRoot() is deprecated since version 2.2 and will be removed in 2.3. There is no substitution ' . + 'because RouteCollection is not tree structure anymore.', E_USER_DEPRECATED); + $parent = $this; while ($parent->getParent()) { $parent = $parent->getParent(); @@ -184,6 +190,8 @@ class RouteCollection implements \IteratorAggregate, \Countable // this is to keep BC $numargs = func_num_args(); if ($numargs > 1) { + trigger_error('addCollection() should only be used with a single parameter. The params $prefix, $defaults, $requirements and $options ' . + 'are deprecated since version 2.2 and will be removed in 2.3. Use addPrefix() and addOptions() instead.', E_USER_DEPRECATED); $collection->addPrefix($this->prefix . func_get_arg(1)); if ($numargs > 2) { $collection->addDefaults(func_get_arg(2)); @@ -232,7 +240,13 @@ class RouteCollection implements \IteratorAggregate, \Countable $this->prefix = '/' . $prefix . $this->prefix; // this is to keep BC - $options = func_num_args() > 3 ? func_get_arg(3) : array(); + if (func_num_args() > 3) { + trigger_error('The fourth parameter ($options) of addPrefix() is deprecated since version 2.2 and will be removed in 2.3. ' . + 'Use addOptions() instead.', E_USER_DEPRECATED); + $options = func_get_arg(3); + } else { + $options = array(); + } foreach ($this->routes as $route) { $route->setPath('/' . $prefix . $route->getPath()); @@ -251,6 +265,9 @@ class RouteCollection implements \IteratorAggregate, \Countable */ public function getPrefix() { + trigger_error('getPrefix() is deprecated since version 2.2 and will be removed in 2.3. The method suggests that ' . + 'all routes in the collection would have this prefix, which is not necessarily true.', E_USER_DEPRECATED); + return $this->prefix; } From 2b8bf6beec4514cfd59f161f77ec813b2eedd5b6 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Fri, 7 Dec 2012 11:09:21 +0100 Subject: [PATCH 10/26] adjusted tests to not use RouteCollection::getPrefix --- .../Component/Routing/Tests/RouteCollectionTest.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php index 65f9967e6a..13a50de87f 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php @@ -133,9 +133,8 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase $collection2 = new RouteCollection(); $collection2->add('bar', $bar = new Route('/bar')); $collection->addCollection($collection2); - $this->assertSame('', $collection->getPrefix(), '->getPrefix() is initialized with ""'); $collection->addPrefix(' / '); - $this->assertSame('', $collection->getPrefix(), '->addPrefix() trims the prefix and a single slash has no effect'); + $this->assertSame('/foo', $collection->get('foo')->getPattern(), '->addPrefix() trims the prefix and a single slash has no effect'); $collection->addPrefix('/{admin}', array('admin' => 'admin'), array('admin' => '\d+'), array('foo' => 'bar')); $this->assertEquals('/{admin}/foo', $collection->get('foo')->getPath(), '->addPrefix() adds a prefix to all routes'); $this->assertEquals('/{admin}/bar', $collection->get('bar')->getPath(), '->addPrefix() adds a prefix to all routes'); @@ -152,11 +151,10 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase $collection->get('bar')->getOptions(), '->addPrefix() adds an option to all routes' ); $collection->addPrefix('0'); - $this->assertEquals('/0/{admin}', $collection->getPrefix(), '->addPrefix() ensures a prefix must start with a slash and must not end with a slash'); + $this->assertEquals('/0/{admin}/foo', $collection->get('foo')->getPattern(), '->addPrefix() ensures a prefix must start with a slash and must not end with a slash'); $collection->addPrefix('/ /'); - $this->assertSame('/ /0/{admin}', $collection->getPrefix(), '->addPrefix() can handle spaces if desired'); - $this->assertSame('/ /0/{admin}/foo', $collection->get('foo')->getPath(), 'the route path is in synch with the collection prefix'); - $this->assertSame('/ /0/{admin}/bar', $collection->get('bar')->getPath(), 'the route path in a sub-collection is in synch with the collection prefix'); + $this->assertSame('/ /0/{admin}/foo', $collection->get('foo')->getPath(), '->addPrefix() can handle spaces if desired'); + $this->assertSame('/ /0/{admin}/bar', $collection->get('bar')->getPath(), 'the route pattern of an added collection is in synch with the added prefix'); } public function testAddPrefixOverridesDefaultsAndRequirements() From ceb9ab44a4796888af79014c65c72c9534e096f9 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Fri, 7 Dec 2012 11:24:42 +0100 Subject: [PATCH 11/26] adjust tests to no use addPrefix with options --- .../Component/Routing/Tests/RouteCollectionTest.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php index 13a50de87f..62d58ca0d2 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php @@ -135,21 +135,13 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase $collection->addCollection($collection2); $collection->addPrefix(' / '); $this->assertSame('/foo', $collection->get('foo')->getPattern(), '->addPrefix() trims the prefix and a single slash has no effect'); - $collection->addPrefix('/{admin}', array('admin' => 'admin'), array('admin' => '\d+'), array('foo' => 'bar')); + $collection->addPrefix('/{admin}', array('admin' => 'admin'), array('admin' => '\d+')); $this->assertEquals('/{admin}/foo', $collection->get('foo')->getPath(), '->addPrefix() adds a prefix to all routes'); $this->assertEquals('/{admin}/bar', $collection->get('bar')->getPath(), '->addPrefix() adds a prefix to all routes'); $this->assertEquals(array('admin' => 'admin'), $collection->get('foo')->getDefaults(), '->addPrefix() adds defaults to all routes'); $this->assertEquals(array('admin' => 'admin'), $collection->get('bar')->getDefaults(), '->addPrefix() adds defaults to all routes'); $this->assertEquals(array('admin' => '\d+'), $collection->get('foo')->getRequirements(), '->addPrefix() adds requirements to all routes'); $this->assertEquals(array('admin' => '\d+'), $collection->get('bar')->getRequirements(), '->addPrefix() adds requirements to all routes'); - $this->assertEquals( - array('foo' => 'bar', 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler'), - $collection->get('foo')->getOptions(), '->addPrefix() adds an option to all routes' - ); - $this->assertEquals( - array('foo' => 'bar', 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler'), - $collection->get('bar')->getOptions(), '->addPrefix() adds an option to all routes' - ); $collection->addPrefix('0'); $this->assertEquals('/0/{admin}/foo', $collection->get('foo')->getPattern(), '->addPrefix() ensures a prefix must start with a slash and must not end with a slash'); $collection->addPrefix('/ /'); From 9e2bcb5d9e7475a18f71f1ca1936c781543750c7 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Fri, 7 Dec 2012 11:44:47 +0100 Subject: [PATCH 12/26] refactor interator test that was still assuming a tree --- .../Routing/Tests/RouteCollectionTest.php | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php index 62d58ca0d2..9cccd4c34a 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php @@ -54,16 +54,19 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase $this->assertEquals('/foo2', $collection->get('foo')->getPath()); } - public function testIteratorWithOverriddenRoutes() + public function testIterator() { $collection = new RouteCollection(); $collection->add('foo', new Route('/foo')); $collection1 = new RouteCollection(); - $collection1->add('foo', new Route('/foo1')); + $collection1->add('bar', $bar = new Route('/bar')); + $collection1->add('foo', $foo = new Route('/foo-new')); $collection->addCollection($collection1); + $collection->add('last', $last = new Route('/last')); - $this->assertEquals('/foo1', $this->getFirstNamedRoute($collection, 'foo')->getPath()); + $this->assertInstanceOf('\ArrayIterator', $collection->getIterator()); + $this->assertSame(array('bar' => $bar, 'foo' => $foo, 'last' => $last), $collection->getIterator()->getArrayCopy()); } public function testCount() @@ -72,25 +75,12 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase $collection->add('foo', new Route('/foo')); $collection1 = new RouteCollection(); - $collection1->add('foo1', new Route('/foo1')); + $collection1->add('bar', new Route('/bar')); $collection->addCollection($collection1); $this->assertCount(2, $collection); } - protected function getFirstNamedRoute(RouteCollection $routeCollection, $name) - { - foreach ($routeCollection as $key => $route) { - if ($route instanceof RouteCollection) { - return $this->getFirstNamedRoute($route, $name); - } - - if ($name === $key) { - return $route; - } - } - } - public function testAddCollection() { if (!class_exists('Symfony\Component\Config\Resource\FileResource')) { From ea694e445d50b1abe9c83352593015f1b1169aaa Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Fri, 7 Dec 2012 11:59:02 +0100 Subject: [PATCH 13/26] added tests for remove() that wasnt covered yet and special route name --- .../Routing/Tests/RouteCollectionTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php index 9cccd4c34a..487a537a87 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php @@ -197,13 +197,31 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase $collection2 = new RouteCollection(); $collection2->add('b', $b = new Route('/b')); $collection1->addCollection($collection2); + $collection1->add('$péß^a|', $c = new Route('/special')); $this->assertSame($b, $collection1->get('b'), '->get() returns correct route in child collection'); + $this->assertSame($c, $collection1->get('$péß^a|'), '->get() can handle special characters'); $this->assertNull($collection2->get('a'), '->get() does not return the route defined in parent collection'); $this->assertNull($collection1->get('non-existent'), '->get() returns null when route does not exist'); $this->assertNull($collection1->get(0), '->get() does not disclose internal child RouteCollection'); } + public function testRemove() + { + $collection = new RouteCollection(); + $collection->add('foo', $foo = new Route('/foo')); + + $collection1 = new RouteCollection(); + $collection1->add('bar', $bar = new Route('/bar')); + $collection->addCollection($collection1); + $collection->add('last', $last = new Route('/last')); + + $collection->remove('foo'); + $this->assertSame(array('bar' => $bar, 'last' => $last), $collection->all(), '->remove() can remove a single route'); + $collection->remove(array('bar', 'last')); + $this->assertSame(array(), $collection->all(), '->remove() accepts an array and can remove multiple routes at once'); + } + public function testSetHost() { $collection = new RouteCollection(); From 0a1cfcdb5f0f75ad8c69506879eb5b8c38436d35 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Fri, 7 Dec 2012 13:21:35 +0100 Subject: [PATCH 14/26] adjust RouteCollectionTest for the addCollection change and refactor the tests to only skip the part that really needs the config component --- .../Routing/Tests/RouteCollectionTest.php | 54 +++++++------------ 1 file changed, 20 insertions(+), 34 deletions(-) diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php index 487a537a87..09748de0f3 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php @@ -82,32 +82,31 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase } public function testAddCollection() + { + $collection = new RouteCollection(); + $collection->add('foo', new Route('/foo')); + + $collection1 = new RouteCollection(); + $collection1->add('bar', $bar = new Route('/bar')); + $collection1->add('foo', $foo = new Route('/foo-new')); + + $collection2 = new RouteCollection(); + $collection2->add('grandchild', $grandchild = new Route('/grandchild')); + + $collection1->addCollection($collection2); + $collection->addCollection($collection1); + $collection->add('last', $last = new Route('/last')); + + $this->assertSame(array('bar' => $bar, 'foo' => $foo, 'grandchild' => $grandchild, 'last' => $last), $collection->all(), + '->addCollection() imports routes of another collection, overrides if necessary and adds them at the end'); + } + + public function testAddCollectionWithResources() { if (!class_exists('Symfony\Component\Config\Resource\FileResource')) { $this->markTestSkipped('The "Config" component is not available'); } - $collection = new RouteCollection(); - $collection->add('foo', $foo = new Route('/foo')); - $collection1 = new RouteCollection(); - $collection1->add('foo', $foo1 = new Route('/foo1')); - $collection1->add('bar', $bar1 = new Route('/bar1')); - $collection->addCollection($collection1); - $this->assertEquals(array('foo' => $foo1, 'bar' => $bar1), $collection->all(), '->addCollection() adds routes from another collection'); - - $collection = new RouteCollection(); - $collection->add('foo', $foo = new Route('/foo')); - $collection1 = new RouteCollection(); - $collection1->add('foo', $foo1 = new Route('/foo1')); - $collection->addCollection($collection1, '/{foo}', array('foo' => 'foo'), array('foo' => '\d+'), array('foo' => 'bar')); - $this->assertEquals('/{foo}/foo1', $collection->get('foo')->getPath(), '->addCollection() can add a prefix to all merged routes'); - $this->assertEquals(array('foo' => 'foo'), $collection->get('foo')->getDefaults(), '->addCollection() can add a prefix to all merged routes'); - $this->assertEquals(array('foo' => '\d+'), $collection->get('foo')->getRequirements(), '->addCollection() can add a prefix to all merged routes'); - $this->assertEquals( - array('foo' => 'bar', 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler'), - $collection->get('foo')->getOptions(), '->addCollection() can add an option to all merged routes' - ); - $collection = new RouteCollection(); $collection->addResource($foo = new FileResource(__DIR__.'/Fixtures/foo.xml')); $collection1 = new RouteCollection(); @@ -150,19 +149,6 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase $this->assertEquals('https', $collection->get('bar')->getRequirement('_scheme'), '->addPrefix() overrides existing requirements'); } - public function testAddCollectionOverridesDefaultsAndRequirements() - { - $imported = new RouteCollection(); - $imported->add('foo', $foo = new Route('/foo')); - $imported->add('bar', $bar = new Route('/bar', array(), array('_scheme' => 'http'))); - - $collection = new RouteCollection(); - $collection->addCollection($imported, null, array(), array('_scheme' => 'https')); - - $this->assertEquals('https', $collection->get('foo')->getRequirement('_scheme'), '->addCollection() overrides existing requirements'); - $this->assertEquals('https', $collection->get('bar')->getRequirement('_scheme'), '->addCollection() overrides existing requirements'); - } - public function testResource() { if (!class_exists('Symfony\Component\Config\Resource\FileResource')) { From c0de07b9603602af3f33f82883683e7ff957952e Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Fri, 7 Dec 2012 13:22:39 +0100 Subject: [PATCH 15/26] added tests for addDefaults, addRequirements, addOptions --- .../Routing/Tests/RouteCollectionTest.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php index 09748de0f3..d60d1c68af 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php @@ -115,6 +115,33 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase $this->assertEquals(array($foo, $foo1), $collection->getResources(), '->addCollection() merges resources'); } + public function testAddDefaultsAndRequirementsAndOptions() + { + $collection = new RouteCollection(); + $collection->add('foo', new Route('/{placeholder}')); + $collection1 = new RouteCollection(); + $collection1->add('bar', new Route('/{placeholder}', + array('_controller' => 'fixed', 'placeholder' => 'default'), array('placeholder' => '.+'), array('option' => 'value')) + ); + $collection->addCollection($collection1); + + $collection->addDefaults(array('placeholder' => 'new-default')); + $this->assertEquals(array('placeholder' => 'new-default'), $collection->get('foo')->getDefaults(), '->addDefaults() adds defaults to all routes'); + $this->assertEquals(array('_controller' => 'fixed', 'placeholder' => 'new-default'), $collection->get('bar')->getDefaults(), + '->addDefaults() adds defaults to all routes and overwrites existing ones'); + + $collection->addRequirements(array('placeholder' => '\d+')); + $this->assertEquals(array('placeholder' => '\d+'), $collection->get('foo')->getRequirements(), '->addRequirements() adds requirements to all routes'); + $this->assertEquals(array('placeholder' => '\d+'), $collection->get('bar')->getRequirements(), + '->addRequirements() adds requirements to all routes and overwrites existing ones'); + + $collection->addOptions(array('option' => 'new-value')); + $this->assertEquals( + array('option' => 'new-value', 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler'), + $collection->get('bar')->getOptions(), '->addOptions() adds options to all routes and overwrites existing ones' + ); + } + public function testAddPrefix() { $collection = new RouteCollection(); From 6180c5b031d0d0117786f514a3f8a46efa938a9b Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Fri, 7 Dec 2012 13:28:59 +0100 Subject: [PATCH 16/26] add test for uniqueness of resources --- src/Symfony/Component/Routing/Tests/RouteCollectionTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php index d60d1c68af..901317663f 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php @@ -184,7 +184,11 @@ class RouteCollectionTest extends \PHPUnit_Framework_TestCase $collection = new RouteCollection(); $collection->addResource($foo = new FileResource(__DIR__.'/Fixtures/foo.xml')); - $this->assertEquals(array($foo), $collection->getResources(), '->addResources() adds a resource'); + $collection->addResource($bar = new FileResource(__DIR__.'/Fixtures/bar.xml')); + $collection->addResource(new FileResource(__DIR__.'/Fixtures/foo.xml')); + + $this->assertEquals(array($foo, $bar), $collection->getResources(), + '->addResource() adds a resource and getResources() only returns unique ones by comparing the string representation'); } public function testUniqueRouteWithGivenName() From 708c0d3ff9275b105719dba305163d5ceeb88236 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Fri, 7 Dec 2012 14:29:35 +0100 Subject: [PATCH 17/26] adjust routing tests to not use prefix in addCollection --- .../Dumper/ApacheMatcherDumperTest.php | 3 +- .../Matcher/Dumper/PhpMatcherDumperTest.php | 31 ++++++++++++------- .../Routing/Tests/Matcher/UrlMatcherTest.php | 20 ++++-------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php index da72d6b3a9..72bee71002 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php @@ -150,7 +150,8 @@ class ApacheMatcherDumperTest extends \PHPUnit_Framework_TestCase $route3 = new Route('/route3', array(), array(), array(), 'b.example.com'); $collection2->add('route3', $route3); - $collection1->addCollection($collection2, '/c2'); + $collection2->addPrefix('/c2'); + $collection1->addCollection($collection2); $route4 = new Route('/route4', array(), array(), array(), 'a.example.com'); $collection1->add('route4', $route4); diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php index 4764df617d..542ede85c0 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php @@ -118,14 +118,17 @@ class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase $collection1->add('overridden', new Route('/overridden1')); $collection1->add('foo1', new Route('/{foo}')); $collection1->add('bar1', new Route('/{bar}')); + $collection1->addPrefix('/b\'b'); $collection2 = new RouteCollection(); - $collection2->addCollection($collection1, '/b\'b'); + $collection2->addCollection($collection1); $collection2->add('overridden', new Route('/{var}', array(), array('var' => '.*'))); $collection1 = new RouteCollection(); $collection1->add('foo2', new Route('/{foo1}')); $collection1->add('bar2', new Route('/{bar1}')); - $collection2->addCollection($collection1, '/b\'b'); - $collection->addCollection($collection2, '/a'); + $collection1->addPrefix('/b\'b'); + $collection2->addCollection($collection1); + $collection2->addPrefix('/a'); + $collection->addCollection($collection2); // overridden through addCollection() and multiple sub-collections with no own prefix $collection1 = new RouteCollection(); @@ -137,15 +140,16 @@ class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase $collection3->add('hey', new Route('/hey/')); $collection2->addCollection($collection3); $collection1->addCollection($collection2); - $collection->addCollection($collection1, '/multi'); + $collection1->addPrefix('/multi'); + $collection->addCollection($collection1); // "dynamic" prefix $collection1 = new RouteCollection(); $collection1->add('foo3', new Route('/{foo}')); $collection1->add('bar3', new Route('/{bar}')); - $collection2 = new RouteCollection(); - $collection2->addCollection($collection1, '/b'); - $collection->addCollection($collection2, '/{_locale}'); + $collection1->addPrefix('/b'); + $collection1->addPrefix('{_locale}'); + $collection->addCollection($collection1); // route between collections $collection->add('ababa', new Route('/ababa')); @@ -153,7 +157,8 @@ class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase // collection with static prefix but only one route $collection1 = new RouteCollection(); $collection1->add('foo4', new Route('/{foo}')); - $collection->addCollection($collection1, '/aba'); + $collection1->addPrefix('/aba'); + $collection->addCollection($collection1); // prefix and host @@ -215,10 +220,12 @@ class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase $collection2->add('b', new Route('/{var}')); $collection3 = new RouteCollection(); $collection3->add('c', new Route('/{var}')); - - $collection2->addCollection($collection3, '/c'); - $collection1->addCollection($collection2, '/b'); - $collection->addCollection($collection1, '/a'); + $collection3->addPrefix('/c'); + $collection2->addCollection($collection3); + $collection2->addPrefix('/b'); + $collection1->addCollection($collection2); + $collection1->addPrefix('/a'); + $collection->addCollection($collection1); /* test case 2 */ diff --git a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php index fee6fe2b6f..8a1428f170 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php @@ -130,14 +130,10 @@ class UrlMatcherTest extends \PHPUnit_Framework_TestCase public function testMatchWithPrefixes() { - $collection1 = new RouteCollection(); - $collection1->add('foo', new Route('/{foo}')); - - $collection2 = new RouteCollection(); - $collection2->addCollection($collection1, '/b'); - $collection = new RouteCollection(); - $collection->addCollection($collection2, '/a'); + $collection->add('foo', new Route('/{foo}')); + $collection->addPrefix('/b'); + $collection->addPrefix('/a'); $matcher = new UrlMatcher($collection, new RequestContext()); $this->assertEquals(array('_route' => 'foo', 'foo' => 'foo'), $matcher->match('/a/b/foo')); @@ -145,14 +141,10 @@ class UrlMatcherTest extends \PHPUnit_Framework_TestCase public function testMatchWithDynamicPrefix() { - $collection1 = new RouteCollection(); - $collection1->add('foo', new Route('/{foo}')); - - $collection2 = new RouteCollection(); - $collection2->addCollection($collection1, '/b'); - $collection = new RouteCollection(); - $collection->addCollection($collection2, '/{_locale}'); + $collection->add('foo', new Route('/{foo}')); + $collection->addPrefix('/b'); + $collection->addPrefix('/{_locale}'); $matcher = new UrlMatcher($collection, new RequestContext()); $this->assertEquals(array('_locale' => 'fr', '_route' => 'foo', 'foo' => 'foo'), $matcher->match('/fr/b/foo')); From c0687cd5fa118d807f1a7593abc5abbdfbe764f4 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Tue, 5 Mar 2013 12:20:45 +0100 Subject: [PATCH 18/26] remove() should not use deprecated getParent() so it does not trigger deprecation internally --- src/Symfony/Component/Routing/RouteCollection.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Routing/RouteCollection.php b/src/Symfony/Component/Routing/RouteCollection.php index ffdf57f478..b60b7f3d2c 100644 --- a/src/Symfony/Component/Routing/RouteCollection.php +++ b/src/Symfony/Component/Routing/RouteCollection.php @@ -163,7 +163,10 @@ class RouteCollection implements \IteratorAggregate, \Countable public function remove($name) { // just for BC - $root = $this->getRoot(); + $root = $this; + while ($root->parent) { + $root = $root->parent; + } foreach ((array) $name as $n) { unset($root->routes[$n]); From 709518bafde2e0fb60948fe7d1f8de13bd2f505c Mon Sep 17 00:00:00 2001 From: Maksim Muruev Date: Wed, 6 Mar 2013 09:31:41 +0200 Subject: [PATCH 19/26] Default validation message translation fix. Add 'validators' for $translationDomain. Detailed discussion https://github.com/fabpot/Silex/pull/641 --- src/Symfony/Component/Validator/Validator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Validator.php b/src/Symfony/Component/Validator/Validator.php index 8221d60266..202e1e2f10 100644 --- a/src/Symfony/Component/Validator/Validator.php +++ b/src/Symfony/Component/Validator/Validator.php @@ -52,7 +52,7 @@ class Validator implements ValidatorInterface MetadataFactoryInterface $metadataFactory, ConstraintValidatorFactoryInterface $validatorFactory, TranslatorInterface $translator, - $translationDomain = null, + $translationDomain = 'validators', array $objectInitializers = array() ) { From e86fefa709965ccaf67cef371ca2041786161b17 Mon Sep 17 00:00:00 2001 From: chx Date: Mon, 4 Mar 2013 13:57:29 -0800 Subject: [PATCH 20/26] Unset loading[$id] in ContainerBuilder on exception --- .../Component/DependencyInjection/ContainerBuilder.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index deb65875ea..71379ef1e8 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -350,7 +350,12 @@ class ContainerBuilder extends Container implements TaggedContainerInterface $this->loading[$id] = true; - $service = $this->createService($definition, $id); + try { + $service = $this->createService($definition, $id); + } catch (\Exception $e) { + unset($this->loading[$id]); + throw $e; + } unset($this->loading[$id]); From dcb1441d23fcd4d51608deaab0f4d484cd80e20b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 6 Mar 2013 17:38:10 +0100 Subject: [PATCH 21/26] [DependencyInjection] added a test for the previous merge (refs #7261) --- .../Tests/ContainerBuilderTest.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index c2677d326c..48dd10acf5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -19,6 +19,7 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\Config\Resource\FileResource; @@ -116,6 +117,26 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase $this->assertTrue($builder->get('bar') === $builder->get('bar'), '->get() always returns the same instance if the service is shared'); } + /** + * @covers \Symfony\Component\DependencyInjection\ContainerBuilder::get + * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException + * @expectedExceptionMessage You have requested a synthetic service ("foo"). The DIC does not know how to construct this service. + */ + public function testGetXXX() + { + $builder = new ContainerBuilder(); + $builder->register('foo', 'stdClass')->setSynthetic(true); + + // we expect a RuntimeException here as foo is synthetic + try { + $builder->get('foo'); + } catch (RuntimeException $e) { + } + + // we must also have the same RuntimeException here + $builder->get('foo'); + } + /** * @covers Symfony\Component\DependencyInjection\ContainerBuilder::getServiceIds */ From c82c754b8e094796993e69718275e574444c0fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kerner?= Date: Fri, 22 Feb 2013 23:27:38 +0100 Subject: [PATCH 22/26] RedisProfilerStorage wrong db-number/index-number selected --- .../HttpKernel/Profiler/RedisProfilerStorage.php | 10 ++++++++-- .../HttpKernel/Tests/Profiler/Mock/RedisMock.php | 13 +++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php index e981d75f61..d601653bb8 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php @@ -193,12 +193,13 @@ class RedisProfilerStorage implements ProfilerStorageInterface protected function getRedis() { if (null === $this->redis) { - if (!preg_match('#^redis://(?(?=\[.*\])\[(.*)\]|(.*)):(.*)$#', $this->dsn, $matches)) { - throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Redis with an invalid dsn "%s". The expected format is "redis://[host]:port".', $this->dsn)); + if (!preg_match('#^redis://(?(?=\[.*\])\[(.*)\]|(.*)):(\d+)(/(\d+))?$#', $this->dsn, $matches)) { + throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Redis with an invalid dsn "%s". The expected format is "redis://[host]:port[/db-number]".', $this->dsn)); } $host = $matches[1] ?: $matches[2]; $port = $matches[3]; + $dbnum = !empty($matches[5]) ? intval($matches[5]) : -1; if (!extension_loaded('redis')) { throw new \RuntimeException('RedisProfilerStorage requires that the redis extension is loaded.'); @@ -206,6 +207,11 @@ class RedisProfilerStorage implements ProfilerStorageInterface $redis = new Redis; $redis->connect($host, $port); + + // if a valid dbnumber is given select the redis index + if (-1 < $dbnum) { + $redis->select($dbnum); + } $redis->setOption(self::REDIS_OPT_PREFIX, self::TOKEN_PREFIX); diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php index 4b8cf07a66..122479b922 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php +++ b/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php @@ -238,4 +238,17 @@ class RedisMock return true; } + + public function select($dbnum) + { + if (!$this->connected) { + return false; + } + + if (0 > $dbnum) { + return false; + } + + return true; + } } From 22c1aa3636f4eaa4b606d0d76e555aeaf2994a0b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 6 Mar 2013 17:55:57 +0100 Subject: [PATCH 23/26] fixed typo --- .../DependencyInjection/Tests/ContainerBuilderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 48dd10acf5..58ae5f65f6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -122,7 +122,7 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException * @expectedExceptionMessage You have requested a synthetic service ("foo"). The DIC does not know how to construct this service. */ - public function testGetXXX() + public function testGetUnsetLoadingServiceWhenCreateServiceThrowsAnException() { $builder = new ContainerBuilder(); $builder->register('foo', 'stdClass')->setSynthetic(true); From ac0c4ceeb378ef84f21e1f8a0a0570f20ac64a39 Mon Sep 17 00:00:00 2001 From: Wouter J Date: Wed, 6 Mar 2013 17:58:18 +0100 Subject: [PATCH 24/26] Fixed typo in UPGRADE-2.2 --- UPGRADE-2.2.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/UPGRADE-2.2.md b/UPGRADE-2.2.md index e4494eeda8..524a8f7e1d 100644 --- a/UPGRADE-2.2.md +++ b/UPGRADE-2.2.md @@ -202,10 +202,10 @@ ``` use Symfony\Component\PropertyAccess\PropertyAccess; - $accessor = PropertyAccess::getPropertyAccessor(); + $propertyAccessor = PropertyAccess::getPropertyAccessor(); $value = $propertyAccessor->getValue($object, 'some.path'); - $accessor->setValue($object, 'some.path', 'new value'); + $propertyAccessor->setValue($object, 'some.path', 'new value'); ``` After (alternative 2): @@ -214,11 +214,11 @@ use Symfony\Component\PropertyAccess\PropertyAccess; use Symfony\Component\PropertyAccess\PropertyPath; - $accessor = PropertyAccess::getPropertyAccessor(); + $propertyAccessor = PropertyAccess::getPropertyAccessor(); $propertyPath = new PropertyPath('some.path'); $value = $propertyAccessor->getValue($object, $propertyPath); - $accessor->setValue($object, $propertyPath, 'new value'); + $propertyAccessor->setValue($object, $propertyPath, 'new value'); ``` ### Routing From 9d88495817e2ebe841ca2323c73382a8f82ef6db Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Tue, 5 Mar 2013 09:51:02 +0100 Subject: [PATCH 25/26] remove dead code in yaml component --- src/Symfony/Component/Yaml/Inline.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 0d791ca41d..e967b6b9c7 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -235,11 +235,6 @@ class Inline */ private static function parseQuotedScalar($scalar, &$i) { - // Only check the current item we're dealing with (for sequences) - $subject = substr($scalar, $i); - $items = preg_split('/[\'"]\s*(?:[,:]|[}\]]\s*,)/', $subject); - $subject = substr($subject, 0, strlen($items[0]) + 1); - if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) { throw new ParseException(sprintf('Malformed inline YAML string (%s).', substr($scalar, $i))); } From d1f5d254838fecf25cbec07947c84cee2bc465b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Simon?= Date: Fri, 1 Mar 2013 17:33:44 +0100 Subject: [PATCH 26/26] [FrameworkBundle] Fixes invalid serialized objects in cache --- .../Command/CacheClearCommand.php | 35 ++++++++++++------- .../FrameworkExtension.php | 2 +- .../Resources/config/routing.xml | 4 +-- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php index a9aa7a5b8f..99a0f2e88c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php @@ -104,10 +104,31 @@ EOF $warmer->warmUp($warmupDir); + foreach (Finder::create()->files()->name('*.meta')->in($warmupDir) as $file) { + // fix meta references to the Kernel + $content = preg_replace( + '/C\:\d+\:"'.preg_quote($class.$this->getTempKernelSuffix(), '"/').'"/', + sprintf('C:%s:"%s"', strlen($class), $class), + file_get_contents($file) + ); + + // fix meta references to cache files + $realWarmupDir = substr($warmupDir, 0, -4); + $content = preg_replace_callback( + '/s\:\d+\:"'.preg_quote($warmupDir, '/').'([^"]+)"/', + function (array $matches) use ($realWarmupDir) { + $path = $realWarmupDir.$matches[1]; + return sprintf('s:%s:"%s"', strlen($path), $path); + }, + $content + ); + + file_put_contents($file, $content); + } + // fix container files and classes $regex = '/'.preg_quote($this->getTempKernelSuffix(), '/').'/'; - $finder = new Finder(); - foreach ($finder->files()->name(get_class($kernel->getContainer()).'*')->in($warmupDir) as $file) { + foreach (Finder::create()->files()->name(get_class($kernel->getContainer()).'*')->in($warmupDir) as $file) { $content = file_get_contents($file); $content = preg_replace($regex, '', $content); @@ -117,16 +138,6 @@ EOF file_put_contents(preg_replace($regex, '', $file), $content); unlink($file); } - - // fix meta references to the Kernel - foreach ($finder->files()->name('*.meta')->in($warmupDir) as $file) { - $content = preg_replace( - '/C\:\d+\:"'.preg_quote($class.$this->getTempKernelSuffix(), '"/').'"/', - sprintf('C:%s:"%s"', strlen($class), $class), - file_get_contents($file) - ); - file_put_contents($file, $content); - } } protected function getTempKernelSuffix() diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 0b69d8c9c2..0399249d4d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -246,8 +246,8 @@ class FrameworkExtension extends Extension $loader->load('routing.xml'); $container->setParameter('router.resource', $config['resource']); + $container->setParameter('router.cache_class_prefix', $container->getParameter('kernel.name').ucfirst($container->getParameter('kernel.environment'))); $router = $container->findDefinition('router.default'); - $argument = $router->getArgument(2); $argument['strict_requirements'] = $config['strict_requirements']; if (isset($config['type'])) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml index ff6c6f5851..339e17f66e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml @@ -19,8 +19,8 @@ Symfony\Bundle\FrameworkBundle\Routing\RedirectableUrlMatcher Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper Symfony\Bundle\FrameworkBundle\CacheWarmer\RouterCacheWarmer - %kernel.name%%kernel.environment%UrlMatcher - %kernel.name%%kernel.environment%UrlGenerator + %router.cache_class_prefix%UrlMatcher + %router.cache_class_prefix%UrlGenerator Symfony\Component\HttpKernel\EventListener\RouterListener localhost http