From 41bed29c80d82be6e47495585e59566b5d9f9419 Mon Sep 17 00:00:00 2001 From: Tony Malzhacker Date: Thu, 10 May 2012 15:46:21 +0200 Subject: [PATCH 01/11] [Form] fixed invalid 'type' option in ValidatorTypeGuesser for Date/TimeFields Field type guessing breaks, if you use any of the Date/Time constraints, since these field types have no 'type' default option defined. --- .../Form/Extension/Validator/ValidatorTypeGuesser.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php index ef70b54ba6..1dc3be53fb 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php +++ b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php @@ -134,13 +134,13 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface case 'Symfony\Component\Validator\Constraints\Date': return new TypeGuess( 'date', - array('type' => 'string'), + array(), Guess::HIGH_CONFIDENCE ); case 'Symfony\Component\Validator\Constraints\DateTime': return new TypeGuess( 'datetime', - array('type' => 'string'), + array(), Guess::HIGH_CONFIDENCE ); case 'Symfony\Component\Validator\Constraints\Email': @@ -212,7 +212,7 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface case 'Symfony\Component\Validator\Constraints\Time': return new TypeGuess( 'time', - array('type' => 'string'), + array(), Guess::HIGH_CONFIDENCE ); case 'Symfony\Component\Validator\Constraints\Url': From f8839532f8f1964f6b88d56c3d3a9d46088636fe Mon Sep 17 00:00:00 2001 From: Tony Malzhacker Date: Fri, 18 May 2012 17:46:11 +0200 Subject: [PATCH 02/11] TypeGuess fixed for Date/Time constraints --- .../Form/Extension/Validator/ValidatorTypeGuesser.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php index 1dc3be53fb..d09cd8e0c9 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php +++ b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php @@ -134,13 +134,13 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface case 'Symfony\Component\Validator\Constraints\Date': return new TypeGuess( 'date', - array(), + array('input'=>'string'), Guess::HIGH_CONFIDENCE ); case 'Symfony\Component\Validator\Constraints\DateTime': return new TypeGuess( 'datetime', - array(), + array('input'=>'string'), Guess::HIGH_CONFIDENCE ); case 'Symfony\Component\Validator\Constraints\Email': @@ -212,7 +212,7 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface case 'Symfony\Component\Validator\Constraints\Time': return new TypeGuess( 'time', - array(), + array('input'=>'string'), Guess::HIGH_CONFIDENCE ); case 'Symfony\Component\Validator\Constraints\Url': From 03183b5b69205d66b971e490e71e9882374a734b Mon Sep 17 00:00:00 2001 From: Hugo Hamon Date: Tue, 22 May 2012 19:20:01 +0200 Subject: [PATCH 03/11] [Templating] added missing @return PHPDoc for LoaderInterface::isFresh method. --- src/Symfony/Component/Templating/Loader/LoaderInterface.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Component/Templating/Loader/LoaderInterface.php b/src/Symfony/Component/Templating/Loader/LoaderInterface.php index 6dc36343fd..0e5192c63d 100644 --- a/src/Symfony/Component/Templating/Loader/LoaderInterface.php +++ b/src/Symfony/Component/Templating/Loader/LoaderInterface.php @@ -39,6 +39,8 @@ interface LoaderInterface * @param TemplateReferenceInterface $template A template * @param integer $time The last modification time of the cached template (timestamp) * + * @return Boolean + * * @api */ function isFresh(TemplateReferenceInterface $template, $time); From 47a6a2985554f0736ed014b0713cb6ac04d155c4 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Tue, 22 May 2012 22:22:14 +0200 Subject: [PATCH 04/11] [FrameworkBundle] Added a missing dependency to DI The bundle class extends ContainerAware so the DI component is a required dependency of the bundle. --- src/Symfony/Bundle/FrameworkBundle/composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index 90304872ca..a81d6189d4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -17,6 +17,7 @@ ], "require": { "php": ">=5.3.2", + "symfony/dependency-injection": "self.version", "symfony/event-dispatcher": "self.version", "symfony/http-kernel": "self.version", "symfony/routing": "self.version", From 40fd99e9495264f327b2032f085f439a3d851e81 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Tue, 22 May 2012 23:40:54 +0300 Subject: [PATCH 05/11] [FrameworkBundle] Added another missing dependency to Config --- src/Symfony/Bundle/FrameworkBundle/composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index a81d6189d4..1fd9689464 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -17,6 +17,7 @@ ], "require": { "php": ">=5.3.2", + "symfony/config": "self.version", "symfony/dependency-injection": "self.version", "symfony/event-dispatcher": "self.version", "symfony/http-kernel": "self.version", From 7a85b4340b13f5d77d2a9f303a6f9fdba94f2e03 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Tue, 22 May 2012 22:48:33 +0200 Subject: [PATCH 06/11] [TwigBundle] Fixed the path to templates when using composer When installing the bundle and the bridge from the standalone repositories the relative path between them is different. This simply backports the change done in symfony 2.1 to allow using subtree repositories with 2.0.x too. --- .../Bundle/TwigBundle/DependencyInjection/TwigExtension.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index 11e97e8fd8..66a05be0e5 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -55,7 +55,9 @@ class TwigExtension extends Extension $container->setParameter('twig.exception_listener.controller', $config['exception_controller']); $container->setParameter('twig.form.resources', $config['form']['resources']); - $container->getDefinition('twig.loader')->addMethodCall('addPath', array(__DIR__.'/../../../Bridge/Twig/Resources/views/Form')); + + $reflClass = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension'); + $container->getDefinition('twig.loader')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())))); if (!empty($config['globals'])) { $def = $container->getDefinition('twig'); From 95ca5fe11e999d622df2684c08490ca30e99f020 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 23 May 2012 17:39:12 +0200 Subject: [PATCH 07/11] fixed typo --- .../Bundle/TwigBundle/DependencyInjection/TwigExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index 66a05be0e5..31921b322f 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -57,7 +57,7 @@ class TwigExtension extends Extension $container->setParameter('twig.form.resources', $config['form']['resources']); $reflClass = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension'); - $container->getDefinition('twig.loader')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())))); + $container->getDefinition('twig.loader')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())).'/Resources/views/Form')); if (!empty($config['globals'])) { $def = $container->getDefinition('twig'); From 7f93bf1f5bab6ecce8797a58ea2d3b58cfcc988a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 24 May 2012 16:44:36 +0200 Subject: [PATCH 08/11] [TwigBundle] fixed a PHP warning (closes #4397) --- .../Bundle/TwigBundle/Controller/ExceptionController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php b/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php index d676f82086..009e082919 100644 --- a/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php +++ b/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php @@ -46,7 +46,7 @@ class ExceptionController extends ContainerAware $this->findTemplate($templating, $format, $code, $this->container->get('kernel')->isDebug()), array( 'status_code' => $code, - 'status_text' => Response::$statusTexts[$code], + 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', 'exception' => $exception, 'logger' => $logger, 'currentContent' => $currentContent, From 8c6c86c9c93cc50234ab274fca5c493c6a220c20 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Thu, 24 May 2012 23:42:04 +0100 Subject: [PATCH 09/11] Added unit tests for AddCacheWarmerPass class. --- .../Compiler/AddCacheWarmerPassTest.php | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php new file mode 100644 index 0000000000..aac8276a68 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\Reference; +use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass; + +class AddCacheWarmerPassTest extends \PHPUnit_Framework_TestCase +{ + public function testThatCacheWarmersAreProcessedInPriorityOrder() + { + $services = array( + 'my_cache_warmer_service1' => array(0 => array('priority' => 100)), + 'my_cache_warmer_service2' => array(0 => array('priority' => 200)), + 'my_cache_warmer_service3' => array() + ); + + $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); + $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); + + $container->expects($this->atLeastOnce()) + ->method('findTaggedServiceIds') + ->will($this->returnValue($services)); + $container->expects($this->atLeastOnce()) + ->method('getDefinition') + ->with('cache_warmer') + ->will($this->returnValue($definition)); + $container->expects($this->atLeastOnce()) + ->method('hasDefinition') + ->with('cache_warmer') + ->will($this->returnValue(true)); + + $definition->expects($this->once()) + ->method('replaceArgument') + ->with(0, array( + new Reference('my_cache_warmer_service2'), + new Reference('my_cache_warmer_service1'), + new Reference('my_cache_warmer_service3') + )); + + $addCacheWarmerPass = new AddCacheWarmerPass(); + $addCacheWarmerPass->process($container); + } + + public function testThatCompilerPassIsIgnoredIfThereIsNoCacheWarmerDefinition() + { + $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); + $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); + + $container->expects($this->never())->method('findTaggedServiceIds'); + $container->expects($this->never())->method('getDefinition'); + $container->expects($this->atLeastOnce()) + ->method('hasDefinition') + ->with('cache_warmer') + ->will($this->returnValue(false)); + $definition->expects($this->never())->method('replaceArgument'); + + $addCacheWarmerPass = new AddCacheWarmerPass(); + $addCacheWarmerPass->process($container); + } +} From 8da880c394b8e91d9797e1f1dfc384f2b46b910f Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Thu, 24 May 2012 23:58:50 +0100 Subject: [PATCH 10/11] Fixed notice in AddCacheWarmerPass if there is no cache warmer defined. --- .../Compiler/AddCacheWarmerPass.php | 4 ++++ .../Compiler/AddCacheWarmerPassTest.php | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddCacheWarmerPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddCacheWarmerPass.php index abd7b2c00c..a143b557b5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddCacheWarmerPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddCacheWarmerPass.php @@ -37,6 +37,10 @@ class AddCacheWarmerPass implements CompilerPassInterface $warmers[$priority][] = new Reference($id); } + if (empty($warmers)) { + return; + } + // sort by priority and flatten krsort($warmers); $warmers = call_user_func_array('array_merge', $warmers); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php index aac8276a68..03eacc3636 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php @@ -69,4 +69,24 @@ class AddCacheWarmerPassTest extends \PHPUnit_Framework_TestCase $addCacheWarmerPass = new AddCacheWarmerPass(); $addCacheWarmerPass->process($container); } + + public function testThatCacheWarmersMightBeNotDefined() + { + $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); + $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); + + $container->expects($this->atLeastOnce()) + ->method('findTaggedServiceIds') + ->will($this->returnValue(array())); + $container->expects($this->never())->method('getDefinition'); + $container->expects($this->atLeastOnce()) + ->method('hasDefinition') + ->with('cache_warmer') + ->will($this->returnValue(true)); + + $definition->expects($this->never())->method('replaceArgument'); + + $addCacheWarmerPass = new AddCacheWarmerPass(); + $addCacheWarmerPass->process($container); + } } From 35b458f6b886be08af07fb066830054568b9c90f Mon Sep 17 00:00:00 2001 From: jaugustin Date: Thu, 24 May 2012 23:45:33 +0200 Subject: [PATCH 11/11] fix kernel root, linux dir separator on windows, to fix cache:clear issue --- src/Symfony/Component/HttpKernel/Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 732a3a7ea8..bf7b82b364 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -374,7 +374,7 @@ abstract class Kernel implements KernelInterface { if (null === $this->rootDir) { $r = new \ReflectionObject($this); - $this->rootDir = dirname($r->getFileName()); + $this->rootDir = str_replace('\\', '/', dirname($r->getFileName())); } return $this->rootDir;