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
This commit is contained in:
Nicolas Grekas 2016-01-06 10:57:37 +01:00
commit 6cd79e92f6
8 changed files with 30 additions and 22 deletions

View File

@ -158,9 +158,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);

View File

@ -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');
}
}

View File

@ -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';
}

View File

@ -458,7 +458,7 @@ class DialogHelper extends InputAwareHelper
* @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
*

View File

@ -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',

View File

@ -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
*/

View File

@ -780,8 +780,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();
}
@ -1412,7 +1416,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.');
}
@ -1421,7 +1425,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)));
@ -1433,8 +1437,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) {

View File

@ -787,22 +787,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;
}