From 169d5513a615e2a6346c9f4566c0ef86579f8d79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Santoro?= Date: Fri, 1 Jan 2016 15:06:42 +0000 Subject: [PATCH 1/4] Removed spaces before semicolon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'lorem ; ipsum' → 'lorem; ipsum' --- .../TwigBundle/Resources/views/Exception/exception.html.twig | 2 +- src/Symfony/Component/Console/Helper/DialogHelper.php | 2 +- src/Symfony/Component/HttpFoundation/Tests/RequestTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig index f09ffb3c65..546c3f262b 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig +++ b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig @@ -98,7 +98,7 @@ if (clazz) { var tags = document.getElementsByTagName('*'); - for (i = tags.length - 1; i >= 0 ; i--) { + for (i = tags.length - 1; i >= 0; i--) { if (tags[i].className === clazz) { tags[i].style.display = 'none'; } diff --git a/src/Symfony/Component/Console/Helper/DialogHelper.php b/src/Symfony/Component/Console/Helper/DialogHelper.php index 4053e34dbf..3096b5d82a 100644 --- a/src/Symfony/Component/Console/Helper/DialogHelper.php +++ b/src/Symfony/Component/Console/Helper/DialogHelper.php @@ -444,7 +444,7 @@ class DialogHelper extends Helper * @param callable $interviewer A callable that will ask for a question and return the result * @param OutputInterface $output An Output instance * @param callable $validator A PHP callback - * @param int|false $attempts Max number of times to ask before giving up ; false will ask infinitely + * @param int|false $attempts Max number of times to ask before giving up; false will ask infinitely * * @return string The validated response * diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index 5c6790f953..cbc1b74fc9 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -215,7 +215,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase $this->assertEquals('/?foo', $request->getRequestUri()); $this->assertEquals(array('foo' => ''), $request->query->all()); - // assume rewrite rule: (.*) --> app/app.php ; app/ is a symlink to a symfony web/ directory + // assume rewrite rule: (.*) --> app/app.php; app/ is a symlink to a symfony web/ directory $request = Request::create('http://test.com/apparthotel-1234', 'GET', array(), array(), array(), array( 'DOCUMENT_ROOT' => '/var/www/www.test.com', From 1438b9a06763c02c6587f9cc83628bafaf4a7e01 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Wed, 30 Dec 2015 15:01:36 +0100 Subject: [PATCH 2/4] [FrameworkBundle] Set the kernel.name properly after a cache warmup --- .../FrameworkBundle/Command/CacheClearCommand.php | 15 ++++++++++++--- .../CacheClearCommand/CacheClearCommandTest.php | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php index 2b0d1bb9c5..4e4f3fa5f3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php @@ -144,9 +144,18 @@ EOF } // fix references to kernel/container related classes - $search = $tempKernel->getName().ucfirst($tempKernel->getEnvironment()); - $replace = $realKernel->getName().ucfirst($realKernel->getEnvironment()); - foreach (Finder::create()->files()->name($search.'*')->in($warmupDir) as $file) { + $fileSearch = $tempKernel->getName().ucfirst($tempKernel->getEnvironment()).'*'; + $search = array( + $tempKernel->getName().ucfirst($tempKernel->getEnvironment()), + sprintf('\'kernel.name\' => \'%s\'', $tempKernel->getName()), + sprintf('key="kernel.name">%s<', $tempKernel->getName()), + ); + $replace = array( + $realKernel->getName().ucfirst($realKernel->getEnvironment()), + sprintf('\'kernel.name\' => \'%s\'', $realKernel->getName()), + sprintf('key="kernel.name">%s<', $realKernel->getName()), + ); + foreach (Finder::create()->files()->name($fileSearch)->in($warmupDir) as $file) { $content = str_replace($search, $replace, file_get_contents($file)); file_put_contents(str_replace($search, $replace, $file), $content); unlink($file); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php index cb8d1cc6ea..718999d20d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php @@ -83,5 +83,6 @@ class CacheClearCommandTest extends TestCase } } $this->assertTrue($found, 'Kernel file should present as resource'); + $this->assertRegExp(sprintf('/\'kernel.name\'\s*=>\s*\'%s\'/', $this->kernel->getName()), file_get_contents($containerFile), 'kernel.name is properly set on the dumped container'); } } From eab7e11be727ceb3a27a792e3e46307c8cc6e775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1chym=20Tou=C5=A1ek?= Date: Tue, 5 Jan 2016 13:28:14 +0100 Subject: [PATCH 3/4] typo --- src/Symfony/Component/Intl/Locale/Locale.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Intl/Locale/Locale.php b/src/Symfony/Component/Intl/Locale/Locale.php index 23194a064d..cc30c14ffd 100644 --- a/src/Symfony/Component/Intl/Locale/Locale.php +++ b/src/Symfony/Component/Intl/Locale/Locale.php @@ -306,7 +306,7 @@ class Locale * * @return bool true on success or false on failure * - * @see http://www.php.net/manual/en/locale.parselocale.php + * @see http://www.php.net/manual/en/locale.setdefault.php * * @throws MethodNotImplementedException */ From b114a8560968251994833082fc9b63d1234f00a4 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 6 Jan 2016 09:44:17 +0100 Subject: [PATCH 4/4] [Process] Fix potential race condition --- src/Symfony/Component/Process/Process.php | 16 ++++++++++------ .../Component/Process/Tests/ProcessTest.php | 12 +++--------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index c7c536b766..e0f49a7e3b 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -651,8 +651,12 @@ class Process } } - $this->updateStatus(false); - if ($this->processInformation['running']) { + if ($this->isRunning()) { + if (isset($this->fallbackStatus['pid'])) { + unset($this->fallbackStatus['pid']); + + return $this->stop(0, $signal); + } $this->close(); } @@ -1145,7 +1149,7 @@ class Process */ private function doSignal($signal, $throwException) { - if (!$this->isRunning()) { + if (null === $pid = $this->getPid()) { if ($throwException) { throw new LogicException('Can not send signal on a non running process.'); } @@ -1154,7 +1158,7 @@ class Process } if ('\\' === DIRECTORY_SEPARATOR) { - exec(sprintf('taskkill /F /T /PID %d 2>&1', $this->getPid()), $output, $exitCode); + exec(sprintf('taskkill /F /T /PID %d 2>&1', $pid), $output, $exitCode); if ($exitCode && $this->isRunning()) { if ($throwException) { throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output))); @@ -1166,8 +1170,8 @@ class Process if (!$this->enhanceSigchildCompatibility || !$this->isSigchildEnabled()) { $ok = @proc_terminate($this->process, $signal); } elseif (function_exists('posix_kill')) { - $ok = @posix_kill($this->getPid(), $signal); - } elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $this->getPid()), array(2 => array('pipe', 'w')), $pipes)) { + $ok = @posix_kill($pid, $signal); + } elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), array(2 => array('pipe', 'w')), $pipes)) { $ok = false === fgets($pipes[2]); } if (!$ok) { diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 35d48ed081..7fc370bf81 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -685,22 +685,16 @@ class ProcessTest extends \PHPUnit_Framework_TestCase */ public function testRunProcessWithTimeout() { - $timeout = 0.1; - $process = $this->getProcess(self::$phpBin.' -r "sleep(1);"'); - $process->setTimeout($timeout); + $process = $this->getProcess(self::$phpBin.' -r "sleep(30);"'); + $process->setTimeout(0.1); $start = microtime(true); try { $process->run(); $this->fail('A RuntimeException should have been raised'); } catch (RuntimeException $e) { } - $duration = microtime(true) - $start; - if ('\\' !== DIRECTORY_SEPARATOR) { - // On Windows, timers are too transient - $maxDuration = $timeout + 2 * Process::TIMEOUT_PRECISION; - $this->assertLessThan($maxDuration, $duration); - } + $this->assertLessThan(15, microtime(true) - $start); throw $e; }