From fa01e6b4d39aa0df85b0e283b79d00b55879e3e1 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 14 Aug 2013 17:41:18 +0200 Subject: [PATCH 1/4] [Process] Fix for #8754 (Timed-out processes are successful) --- src/Symfony/Component/Process/Process.php | 4 ++-- .../Component/Process/Tests/AbstractProcessTest.php | 1 + .../Process/Tests/SigchildDisabledProcessTest.php | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 3eaaf78871..5a230780fa 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -646,9 +646,9 @@ class Process $timeoutMicro = microtime(true) + $timeout; if ($this->isRunning()) { proc_terminate($this->process); - while ($this->isRunning() && microtime(true) < $timeoutMicro) { + do { usleep(1000); - } + } while ($this->isRunning() && microtime(true) < $timeoutMicro); if ($this->isRunning() && !$this->isSigchildEnabled()) { if (null !== $signal || defined('SIGKILL')) { diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 3afd583086..36936a54b5 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -444,6 +444,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase $duration = microtime(true) - $start; $this->assertLessThan($timeout + $precision, $duration); + $this->assertFalse($process->isSuccessful()); } public function testGetPid() diff --git a/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php b/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php index 8779263736..32b8270d04 100644 --- a/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php +++ b/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php @@ -61,6 +61,14 @@ class SigchildDisabledProcessTest extends AbstractProcessTest parent::testProcessWithoutTermSignal(); } + /** + * @expectedException \Symfony\Component\Process\Exception\RuntimeException + */ + public function testCheckTimeoutOnStartedProcess() + { + parent::testCheckTimeoutOnStartedProcess(); + } + /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException */ From c342715679d0a372799689897dde5b36739f8b47 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 15 Aug 2013 14:37:02 +0200 Subject: [PATCH 2/4] [Form] Fixed: Added "validation_groups" option to submit button --- .../Type/SubmitTypeValidatorExtension.php | 4 +- .../Type/BaseValidatorExtensionTest.php | 74 +++++++++++++++++++ .../Type/FormTypeValidatorExtensionTest.php | 61 ++------------- .../Type/SubmitTypeValidatorExtensionTest.php | 20 +++++ 4 files changed, 101 insertions(+), 58 deletions(-) create mode 100644 src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php create mode 100644 src/Symfony/Component/Form/Tests/Extension/Validator/Type/SubmitTypeValidatorExtensionTest.php diff --git a/src/Symfony/Component/Form/Extension/Validator/Type/SubmitTypeValidatorExtension.php b/src/Symfony/Component/Form/Extension/Validator/Type/SubmitTypeValidatorExtension.php index 5aad67fb3a..ff1c762ef0 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Type/SubmitTypeValidatorExtension.php +++ b/src/Symfony/Component/Form/Extension/Validator/Type/SubmitTypeValidatorExtension.php @@ -11,12 +11,10 @@ namespace Symfony\Component\Form\Extension\Validator\Type; -use Symfony\Component\Form\AbstractTypeExtension; - /** * @author Bernhard Schussek */ -class SubmitTypeValidatorExtension extends AbstractTypeExtension +class SubmitTypeValidatorExtension extends BaseValidatorExtension { /** * {@inheritdoc} diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php new file mode 100644 index 0000000000..fd437c50ea --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php @@ -0,0 +1,74 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Extension\Validator\Type; + +use Symfony\Component\Form\Test\FormInterface; + +/** + * @author Bernhard Schussek + */ +abstract class BaseValidatorExtensionTest extends TypeTestCase +{ + public function testValidationGroupNullByDefault() + { + $form = $this->createForm(); + + $this->assertNull($form->getConfig()->getOption('validation_groups')); + } + + public function testValidationGroupsTransformedToArray() + { + $form = $this->createForm(array( + 'validation_groups' => 'group', + )); + + $this->assertEquals(array('group'), $form->getConfig()->getOption('validation_groups')); + } + + public function testValidationGroupsCanBeSetToArray() + { + $form = $this->createForm(array( + 'validation_groups' => array('group1', 'group2'), + )); + + $this->assertEquals(array('group1', 'group2'), $form->getConfig()->getOption('validation_groups')); + } + + public function testValidationGroupsCanBeSetToFalse() + { + $form = $this->createForm(array( + 'validation_groups' => false, + )); + + $this->assertEquals(array(), $form->getConfig()->getOption('validation_groups')); + } + + public function testValidationGroupsCanBeSetToCallback() + { + $form = $this->createForm(array( + 'validation_groups' => array($this, 'testValidationGroupsCanBeSetToCallback'), + )); + + $this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups'))); + } + + public function testValidationGroupsCanBeSetToClosure() + { + $form = $this->createForm(array( + 'validation_groups' => function(FormInterface $form){ return null; }, + )); + + $this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups'))); + } + + abstract protected function createForm(array $options = array()); +} diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php index 6619410599..0eef62d29c 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php @@ -11,62 +11,8 @@ namespace Symfony\Component\Form\Tests\Extension\Validator\Type; -use Symfony\Component\Form\FormInterface; - -class FormTypeValidatorExtensionTest extends TypeTestCase +class FormTypeValidatorExtensionTest extends BaseValidatorExtensionTest { - public function testValidationGroupNullByDefault() - { - $form = $this->factory->create('form'); - - $this->assertNull($form->getConfig()->getOption('validation_groups')); - } - - public function testValidationGroupsTransformedToArray() - { - $form = $this->factory->create('form', null, array( - 'validation_groups' => 'group', - )); - - $this->assertEquals(array('group'), $form->getConfig()->getOption('validation_groups')); - } - - public function testValidationGroupsCanBeSetToArray() - { - $form = $this->factory->create('form', null, array( - 'validation_groups' => array('group1', 'group2'), - )); - - $this->assertEquals(array('group1', 'group2'), $form->getConfig()->getOption('validation_groups')); - } - - public function testValidationGroupsCanBeSetToFalse() - { - $form = $this->factory->create('form', null, array( - 'validation_groups' => false, - )); - - $this->assertEquals(array(), $form->getConfig()->getOption('validation_groups')); - } - - public function testValidationGroupsCanBeSetToCallback() - { - $form = $this->factory->create('form', null, array( - 'validation_groups' => array($this, 'testValidationGroupsCanBeSetToCallback'), - )); - - $this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups'))); - } - - public function testValidationGroupsCanBeSetToClosure() - { - $form = $this->factory->create('form', null, array( - 'validation_groups' => function(FormInterface $form){ return null; }, - )); - - $this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups'))); - } - public function testSubmitValidatesData() { $builder = $this->factory->createBuilder('form', null, array( @@ -82,4 +28,9 @@ class FormTypeValidatorExtensionTest extends TypeTestCase // specific data is irrelevant $form->submit(array()); } + + protected function createForm(array $options = array()) + { + return $this->factory->create('form', null, $options); + } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/SubmitTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/SubmitTypeValidatorExtensionTest.php new file mode 100644 index 0000000000..c37cf6733c --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/SubmitTypeValidatorExtensionTest.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Extension\Validator\Type; + +class SubmitTypeValidatorExtensionTest extends BaseValidatorExtensionTest +{ + protected function createForm(array $options = array()) + { + return $this->factory->create('submit', null, $options); + } +} From 282b05cbc197275d8c35a2abffbf4d1419d9d1f4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 15 Aug 2013 15:02:15 +0200 Subject: [PATCH 3/4] [HttpKernel] removed unused variable --- src/Symfony/Component/HttpKernel/Kernel.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 0ca2e990ba..9d9295f326 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,7 +59,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $booted; protected $name; protected $startTime; - protected $classes; protected $errorReportingLevel; const VERSION = '2.2.6-DEV'; @@ -84,7 +83,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface $this->booted = false; $this->rootDir = $this->getRootDir(); $this->name = $this->getName(); - $this->classes = array(); $this->bundles = array(); if ($this->debug) { From dbd08551f8ac780f64152e548c798c8d94027d99 Mon Sep 17 00:00:00 2001 From: Christian Morgan Date: Thu, 15 Aug 2013 14:21:20 +0100 Subject: [PATCH 4/4] Added sleep() workaround for windows php rename bug --- .../Bundle/FrameworkBundle/Command/CacheClearCommand.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php index e2bade38a7..dcefd6857b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php @@ -83,6 +83,9 @@ EOF $this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers')); $filesystem->rename($realCacheDir, $oldCacheDir); + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + sleep(1); // workaround for windows php rename bug + } $filesystem->rename($warmupDir, $realCacheDir); }