10000 Merge branch '2.3' into 2.7 · PBWebMedia/symfony@6cd79e9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6cd79e9

Browse files
Merge branch '2.3' into 2.7
* 2.3: [Process] Fix potential race condition typo [FrameworkBundle] Set the kernel.name properly after a cache warmup Removed spaces before semicolon
2 parents 21427de + 707d359 commit 6cd79e9

File tree

8 files changed

+30
-22
lines changed

8 files changed

+30
-22
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,18 @@ protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = tr
158158
}
159159

160160
// fix references to kernel/container related classes
161-
$search = $tempKernel->getName().ucfirst($tempKernel->getEnvironment());
162-
$replace = $realKernel->getName().ucfirst($realKernel->getEnvironment());
163-
foreach (Finder::create()->files()->name($search.'*')->in($warmupDir) as $file) {
161+
$fileSearch = $tempKernel->getName().ucfirst($tempKernel->getEnvironment()).'*';
162+
$search = array(
163+
$tempKernel->getName().ucfirst($tempKernel->getEnvironment()),
164+
sprintf('\'kernel.name\' => \'%s\'', $tempKernel->getName()),
165+
sprintf('key="kernel.name">%s<', $tempKernel->getName()),
166+
);
167+
$replace = array(
168+
$realKernel->getName().ucfirst($realKernel->getEnvironment()),
169+
sprintf('\'kernel.name\' => \'%s\'', $realKernel->getName()),
170+
sprintf('key="kernel.name">%s<', $realKernel->getName()),
171+
);
172+
foreach (Finder::create()->files()->name($fileSearch)->in($warmupDir) as $file) {
164173
$content = str_replace($search, $replace, file_get_contents($file));
165174
file_put_contents(str_replace($search, $replace, $file), $content);
166175
unlink($file);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,6 @@ public function testCacheIsFreshAfterCacheClearedWithWarmup()
8383
}
8484
}
8585
$this->assertTrue($found, 'Kernel file should present as resource');
86+
$this->assertRegExp(sprintf('/\'kernel.name\'\s*=>\s*\'%s\'/', $this->kernel->getName()), file_get_contents($containerFile), 'kernel.name is properly set on the dumped container');
8687
}
8788
}

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

Lines changed: 1 addition & 1 deletion
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
i 8000 f (tags[i].className === clazz) {
103103
tags[i].style.display = 'none';
104104
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ private function hasSttyAvailable()
458458
* @param callable $interviewer A callable that will ask for a question and return the result
459459
* @param OutputInterface $output An Output instance
460460
* @param callable $validator A PHP callback
461-
* @param int|false $attempts Max number of times to ask before giving up ; false will ask infinitely
461+
* @param int|false $attempts Max number of times to ask before giving up; false will ask infinitely
462462
*
463463
* @return string The validated response
464464
*

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public static function parseLocale($locale)
306306
*
307307
* @return bool true on success or false on failure
308308
*
309-
* @see http://www.php.net/manual/en/locale.parselocale.php
309+
* @see http://www.php.net/manual/en/locale.setdefault.php
310310
*
311311
* @throws MethodNotImplementedException
312312
*/

src/Symfony/Component/Process/Process.php

Lines changed: 10 additions & 6 deletions
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

Lines changed: 3 additions & 9 deletions
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)
0