Skip to content

Commit 111f51d

Browse files
Merge branch '2.7' into 2.8
* 2.7: [Process] Fix potential race condition [PhpUnitBridge] Re-enable the garbage collector typo [FrameworkBundle] Set the kernel.name properly after a cache warmup Removed spaces before semicolon
2 parents be80b0a + 6cd79e9 commit 111f51d

File tree

10 files changed

+30
-29
lines changed

10 files changed

+30
-29
lines changed

src/Symfony/Bridge/PhpUnit/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ Provides utilities for PHPUnit, especially user deprecation notices management.
55

66
It comes with the following features:
77

8-
* disable the garbage collector;
98
* enforce a consistent `C` locale;
109
* auto-register `class_exists` to load Doctrine annotations;
1110
* print a user deprecation notices summary at the end of the test suite;

src/Symfony/Bridge/PhpUnit/bootstrap.php

-6
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717
return;
1818
}
1919

20-
if (PHP_VERSION_ID >= 50400 && gc_enabled()) {
21-
// Disabling Zend Garbage Collection to prevent segfaults with PHP5.4+
22-
// https://bugs.php.net/bug.php?id=53976
23-
gc_disable();
24-
}
25-
2620
// Enforce a consistent locale
2721
setlocale(LC_ALL, 'C');
2822

src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

+12-3
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,18 @@ protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = tr
164164
}
165165

166166
// fix references to kernel/container related classes
167-
$search = $tempKernel->getName().ucfirst($tempKernel->getEnvironment());
168-
$replace = $realKernel->getName().ucfirst($realKernel->getEnvironment());
169-
foreach (Finder::create()->files()->name($search.'*')->in($warmupDir) as $file) {
167+
$fileSearch = $tempKernel->getName().ucfirst($tempKernel->getEnvironment()).'*';
168+
$search = array(
169+
$tempKernel->getName().ucfirst($tempKernel->getEnvironment()),
170+
sprintf('\'kernel.name\' => \'%s\'', $tempKernel->getName()),
171+
sprintf('key="kernel.name">%s<', $tempKernel->getName()),
172+
);
173+
$replace = array(
174+
$realKernel->getName().ucfirst($realKernel->getEnvironment()),
175+
sprintf('\'kernel.name\' => \'%s\'', $realKernel->getName()),
176+
sprintf('key="kernel.name">%s<', $realKernel->getName()),
177+
);
178+
foreach (Finder::create()->files()->name($fileSearch)->in($warmupDir) as $file) {
170179
$content = str_replace($search, $replace, file_get_contents($file));
171180
file_put_contents(str_replace($search, $replace, $file), $content);
172181
unlink($file);

src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,6 @@ public function testCacheIsFreshAfterCacheClearedWithWarmup()
8181
}
8282
}
8383
$this->assertTrue($found, 'Kernel file should present as resource');
84+
$this->assertRegExp(sprintf('/\'kernel.name\'\s*=>\s*\'%s\'/', $this->kernel->getName()), file_get_contents($containerFile), 'kernel.name is properly set on the dumped container');
8485
}
8586
}

src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
9999
if (clazz) {
100100
var tags = document.getElementsByTagName('*');
101-
for (i = tags.length - 1; i >= 0 ; i--) {
101+
for (i = tags.length - 1; i >= 0; i--) {
102102
if (tags[i].className === clazz) {
103103
tags[i].style.display = 'none';
104104
}

src/Symfony/Component/Console/Helper/DialogHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ private function hasSttyAvailable()
460460
* @param callable $interviewer A callable that will ask for a question and return the result
461461
* @param OutputInterface $output An Output instance
462462
* @param callable $validator A PHP callback
463-
* @param int|false $attempts Max number of times to ask before giving up ; false will ask infinitely
463+
* @param int|false $attempts Max number of times to ask before giving up; false will ask infinitely
464464
*
465465
* @return string The validated response
466466
*

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public function testCreate()
215215
$this->assertEquals('/?foo', $request->getRequestUri());
216216
$this->assertEquals(array('foo' => ''), $request->query->all());
217217

218-
// assume rewrite rule: (.*) --> app/app.php ; app/ is a symlink to a symfony web/ directory
218+
// assume rewrite rule: (.*) --> app/app.php; app/ is a symlink to a symfony web/ directory
219219
$request = Request::create('http://test.com/apparthotel-1234', 'GET', array(), array(), array(),
220220
array(
221221
'DOCUMENT_ROOT' => '/var/www/www.test.com',

src/Symfony/Component/Intl/Locale/Locale.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ public static function parseLocale($locale)
308308
*
309309
* @return bool true on success or false on failure
310310
*
311-
* @see http://www.php.net/manual/en/locale.parselocale.php
311+
* @see http://www.php.net/manual/en/locale.setdefault.php
312312
*
313313
* @throws MethodNotImplementedException
314314
*/

src/Symfony/Component/Process/Process.php

+10-6
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,12 @@ public function stop($timeout = 10, $signal = null)
780780
}
781781
}
782782

783-
$this->updateStatus(false);
784-
if ($this->processInformation['running']) {
783+
if ($this->isRunning()) {
784+
if (isset($this->fallbackStatus['pid'])) {
785+
unset($this->fallbackStatus['pid']);
786+
787+
return $this->stop(0, $signal);
788+
}
785789
$this->close();
786790
}
787791

@@ -1412,7 +1416,7 @@ private function resetProcessData()
14121416
*/
14131417
private function doSignal($signal, $throwException)
14141418
{
1415-
if (!$this->isRunning()) {
1419+
if (null === $pid = $this->getPid()) {
14161420
if ($throwException) {
14171421
throw new LogicException('Can not send signal on a non running process.');
14181422
}
@@ -1421,7 +1425,7 @@ private function doSignal($signal, $throwException)
14211425
}
14221426

14231427
if ('\\' === DIRECTORY_SEPARATOR) {
1424-
exec(sprintf('taskkill /F /T /PID %d 2>&1', $this->getPid()), $output, $exitCode);
1428+
exec(sprintf('taskkill /F /T /PID %d 2>&1', $pid), $output, $exitCode);
14251429
if ($exitCode && $this->isRunning()) {
14261430
if ($throwException) {
14271431
throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output)));
@@ -1433,8 +1437,8 @@ private function doSignal($signal, $throwException)
14331437
if (!$this->enhanceSigchildCompatibility || !$this->isSigchildEnabled()) {
14341438
$ok = @proc_terminate($this->process, $signal);
14351439
} elseif (function_exists('posix_kill')) {
1436-
$ok = @posix_kill($this->getPid(), $signal);
1437-
} elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $this->getPid()), array(2 => array('pipe', 'w')), $pipes)) {
1440+
$ok = @posix_kill($pid, $signal);
1441+
} elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), array(2 => array('pipe', 'w')), $pipes)) {
14381442
$ok = false === fgets($pipes[2]);
14391443
}
14401444
if (!$ok) {

src/Symfony/Component/Process/Tests/ProcessTest.php

+3-9
Original file line numberDiff line numberDiff line change
@@ -787,22 +787,16 @@ public function testRestart()
787787
*/
788788
public function testRunProcessWithTimeout()
789789
{
790-
$timeout = 0.1;
791-
$process = $this->getProcess(self::$phpBin.' -r "sleep(1);"');
792-
$process->setTimeout($timeout);
790+
$process = $this->getProcess(self::$phpBin.' -r "sleep(30);"');
791+
$process->setTimeout(0.1);
793792
$start = microtime(true);
794793
try {
795794
$process->run();
796795
$this->fail('A RuntimeException should have been raised');
797796
} catch (RuntimeException $e) {
798797
}
799-
$duration = microtime(true) - $start;
800798

801-
if ('\\' !== DIRECTORY_SEPARATOR) {
802-
// On Windows, timers are too transient
803-
$maxDuration = $timeout + 2 * Process::TIMEOUT_PRECISION;
804-
$this->assertLessThan($maxDuration, $duration);
805-
}
799+
$this->assertLessThan(15, microtime(true) - $start);
806800

807801
throw $e;
808802
}

0 commit comments

Comments
 (0)