From 873a5417a8a440f9d4834f0e160fe7954977c9e2 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Sat, 28 Nov 2015 23:15:59 +0100 Subject: [PATCH 1/5] [Console] do not encode backslashes in console default description --- src/Symfony/Component/Console/Descriptor/TextDescriptor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index fffd0e8486..dce6af9f6d 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -187,10 +187,10 @@ class TextDescriptor extends Descriptor private function formatDefaultValue($default) { if (PHP_VERSION_ID < 50400) { - return str_replace('\/', '/', json_encode($default)); + return str_replace(array('\/', '\\\\'), array('/', '\\'), json_encode($default)); } - return json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + return str_replace('\\\\', '\\', json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); } /** From 613804d0cf8871af0e3c151978f5a92f7c274d37 Mon Sep 17 00:00:00 2001 From: Martin Hujer Date: Sun, 29 Nov 2015 08:43:05 +0100 Subject: [PATCH 2/5] [Yaml] minor CS cleaning --- src/Symfony/Component/Yaml/Parser.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 9dffa27811..94a1628afa 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -311,7 +311,7 @@ class Parser if (null === $indentation) { $newIndent = $this->getCurrentLineIndentation(); - $unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem($this->currentLine); + $unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem(); if (!$this->isCurrentLineEmpty() && 0 === $newIndent && !$unindentedEmbedBlock) { throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine); @@ -337,7 +337,7 @@ class Parser return; } - $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine); + $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem(); // Comments must not be removed inside a block scalar $removeCommentsPattern = '~'.self::BLOCK_SCALAR_HEADER_PATTERN.'$~'; @@ -350,7 +350,7 @@ class Parser $removeComments = !preg_match($removeCommentsPattern, $this->currentLine); } - if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine) && $newIndent === $indent) { + if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) { $this->moveToPreviousLine(); break; } @@ -653,7 +653,7 @@ class Parser if ( $this->getCurrentLineIndentation() == $currentIndentation && - $this->isStringUnIndentedCollectionItem($this->currentLine) + $this->isStringUnIndentedCollectionItem() ) { $ret = true; } From ef61e5481f736cf3ff67dd661282fcbd2a2c1504 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 29 Nov 2015 17:56:39 +0100 Subject: [PATCH 3/5] Forward compatibility with AbstractLayout* 2.8 tests --- ...xtensionBootstrap3HorizontalLayoutTest.php | 35 +++++++++++++++++++ .../FormExtensionBootstrap3LayoutTest.php | 25 +++++++++++++ .../Extension/FormExtensionDivLayoutTest.php | 25 +++++++++++++ .../FormExtensionTableLayoutTest.php | 25 +++++++++++++ .../Helper/FormHelperDivLayoutTest.php | 25 +++++++++++++ .../Helper/FormHelperTableLayoutTest.php | 25 +++++++++++++ 6 files changed, 160 insertions(+) diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php index bf26dda05b..c7195ab577 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php @@ -115,4 +115,39 @@ class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3Hori { $this->extension->renderer->setTheme($view, $themes); } + + public function testRange() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testRangeWithMinMaxValues() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testLabelWithoutTranslationOnButton() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testSingleChoiceWithPlaceholderWithoutTranslation() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testButtonlabelWithoutTranslation() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testAttributesNotTranslatedWhenTranslationDomainIsFalse() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php index a9d161b2b9..406c1cef16 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php @@ -125,4 +125,29 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest { // No-op for forward compatibility with AbstractLayoutTest 2.8 } + + public function testLabelWithoutTranslationOnButton() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testSingleChoiceWithPlaceholderWithoutTranslation() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testButtonlabelWithoutTranslation() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testAttributesNotTranslatedWhenTranslationDomainIsFalse() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php index 1bce43b837..9e39ac35dc 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php @@ -218,4 +218,29 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest { // No-op for forward compatibility with AbstractLayoutTest 2.8 } + + public function testLabelWithoutTranslationOnButton() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testSingleChoiceWithPlaceholderWithoutTranslation() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testButtonlabelWithoutTranslation() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testAttributesNotTranslatedWhenTranslationDomainIsFalse() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php index 555ea306fc..7fa88eef00 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php @@ -126,4 +126,29 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest { // No-op for forward compatibility with AbstractLayoutTest 2.8 } + + public function testLabelWithoutTranslationOnButton() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testSingleChoiceWithPlaceholderWithoutTranslation() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testButtonlabelWithoutTranslation() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testAttributesNotTranslatedWhenTranslationDomainIsFalse() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php index 4af5b929cb..217fd5e50e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php @@ -138,4 +138,29 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest { // No-op for forward compatibility with AbstractLayoutTest 2.8 } + + public function testLabelWithoutTranslationOnButton() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testSingleChoiceWithPlaceholderWithoutTranslation() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testButtonlabelWithoutTranslation() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testAttributesNotTranslatedWhenTranslationDomainIsFalse() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php index 1bf641fe1b..99bfba0c4e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php @@ -125,4 +125,29 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest { // No-op for forward compatibility with AbstractLayoutTest 2.8 } + + public function testLabelWithoutTranslationOnButton() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testSingleChoiceWithPlaceholderWithoutTranslation() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testButtonlabelWithoutTranslation() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } + + public function testAttributesNotTranslatedWhenTranslationDomainIsFalse() + { + // No-op for forward compatibility with AbstractLayoutTest 2.8 + } } From 9afbea27e9f8b7d9a976df14a0e40ee88d7214de Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 30 Nov 2015 09:52:07 +0100 Subject: [PATCH 4/5] [Process] Fix signaling/stopping logic on Windows --- src/Symfony/Component/Process/Process.php | 33 +++++++++++------------ 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 1675ad3399..676cddc67e 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -647,22 +647,14 @@ class Process * Stops the process. * * @param int|float $timeout The timeout in seconds - * @param int $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL + * @param int $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL (9) * * @return int The exit-code of the process - * - * @throws RuntimeException if the process got signaled */ public function stop($timeout = 10, $signal = null) { $timeoutMicro = microtime(true) + $timeout; if ($this->isRunning()) { - if ('\\' === DIRECTORY_SEPARATOR && !$this->isSigchildEnabled()) { - exec(sprintf('taskkill /F /T /PID %d 2>&1', $this->getPid()), $output, $exitCode); - if ($exitCode > 0) { - throw new RuntimeException('Unable to kill the process'); - } - } // given `SIGTERM` may not be defined and that `proc_terminate` uses the constant value and not the constant itself, we use the same here $this->doSignal(15, false); do { @@ -670,13 +662,9 @@ class Process } while ($this->isRunning() && microtime(true) < $timeoutMicro); if ($this->isRunning() && !$this->isSigchildEnabled()) { - if (null !== $signal || defined('SIGKILL')) { - // avoid exception here : - // process is supposed to be running, but it might have stop - // just after this line. - // in any case, let's silently discard the error, we can not do anything - $this->doSignal($signal ?: SIGKILL, false); - } + // Avoid exception here: process is supposed to be running, but it might have stopped just + // after this line. In any case, let's silently discard the error, we cannot do anything. + $this->doSignal($signal ?: 9, false); } } @@ -1200,7 +1188,18 @@ class Process return false; } - if (true !== @proc_terminate($this->process, $signal)) { + if ('\\' === DIRECTORY_SEPARATOR) { + exec(sprintf('taskkill /F /T /PID %d 2>&1', $this->getPid()), $output, $exitCode); + if ($exitCode) { + if ($throwException) { + throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output))); + } + + return false; + } + } + + if (true !== @proc_terminate($this->process, $signal) && '\\' !== DIRECTORY_SEPARATOR) { if ($throwException) { throw new RuntimeException(sprintf('Error while sending signal `%s`.', $signal)); } From 346943e2f51fa491a58ca1a2185e5987797f8346 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 30 Nov 2015 11:54:38 +0100 Subject: [PATCH 5/5] add subject variable to expression context --- UPGRADE-2.8.md | 3 +++ .../Security/Core/Authorization/Voter/ExpressionVoter.php | 1 + 2 files changed, 4 insertions(+) diff --git a/UPGRADE-2.8.md b/UPGRADE-2.8.md index 797e2a5015..883ef576d3 100644 --- a/UPGRADE-2.8.md +++ b/UPGRADE-2.8.md @@ -448,6 +448,9 @@ FrameworkBundle Security -------- + * The `object` variable passed to expressions evaluated by the `ExpressionVoter` + is deprecated. Instead use the new `subject` variable. + * The `AbstractVoter` class was deprecated. Instead, extend the `Voter` class and move your voting logic in the `supports($attribute, $subject)` and `voteOnAttribute($attribute, $object, TokenInterface $token)` methods. diff --git a/src/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php b/src/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php index 98b8f50f15..96a7ece998 100644 --- a/src/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php +++ b/src/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php @@ -102,6 +102,7 @@ class ExpressionVoter implements VoterInterface 'token' => $token, 'user' => $token->getUser(), 'object' => $object, + 'subject' => $object, 'roles' => array_map(function ($role) { return $role->getRole(); }, $roles), 'trust_resolver' => $this->trustResolver, );