8000 Merge branch '3.0' · symfony/symfony@b15c734 · GitHub
[go: up one dir, main page]

Skip to content

Commit b15c734

Browse files
Merge branch '3.0'
* 3.0: [Process] Fix potential race condition [PhpUnitBridge] Re-enable the garbage collector typo [FrameworkBundle] Allow to autowire service_container [FrameworkBundle] Set the kernel.name properly after a cache warmup Fix toolbar display when nvd3 is loaded on page Removed spaces before semicolon cast arrays to objects after parsing has finished
2 parents 9feec3d + d14eae4 commit b15c734

File tree

13 files changed

+46
-31
lines changed

13 files changed

+46
-31
lines changed

src/Symfony/Bridge/PhpUnit/README.md

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
return;
1818
}
1919

20-
// Disabling Zend Garbage Collection to prevent segfaults with PHP5.4+
21-
// https://bugs.php.net/bug.php?id=53976
22-
gc_disable();
23-
2420
// Enforce a consistent locale
2521
setlocale(LC_ALL, 'C');
2622

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

Lines changed: 12 additions & 3 deletions
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/Resources/config/services.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
<argument type="collection" />
3030
</service>
3131

32-
<service id="service_container" synthetic="true" />
32+
<service id="service_container" synthetic="true">
33+
<autowiring-type>Symfony\Component\DependencyInjection\ContainerInterface</autowiring-type>
34+
</service>
3335

3436
<service id="kernel" synthetic="true" />
3537

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

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

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
if (tags[i].className === clazz) {
103103
tags[i].style.display = 'none';
104104
}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
.sf-minitoolbar img {
2121
max-height: 24px;
2222
max-width: 24px;
23+
display: inline;
2324
}
2425

2526
.sf-toolbarreset * {

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

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

@@ -1373,7 +1377,7 @@ private function resetProcessData()
13731377
*/
13741378
private function doSignal($signal, $throwException)
13751379
{
1376-
if (!$this->isRunning()) {
1380+
if (null === $pid = $this->getPid()) {
13771381
if ($throwException) {
13781382
throw new LogicException('Can not send signal on a non running process.');
13791383
}
@@ -1382,7 +1386,7 @@ private function doSignal($signal, $throwException)
13821386
}
13831387

13841388
if ('\\' === DIRECTORY_SEPARATOR) {
1385-
exec(sprintf('taskkill /F /T /PID %d 2>&1', $this->getPid()), $output, $exitCode);
1389+
exec(sprintf('taskkill /F /T /PID %d 2>&1', $pid), $output, $exitCode);
13861390
if ($exitCode && $this->isRunning()) {
13871391
if ($throwException) {
13881392
throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output)));
@@ -1394,8 +1398,8 @@ private function doSignal($signal, $throwException)
13941398
if (!$this->enhanceSigchildCompatibility || !$this->isSigchildEnabled()) {
13951399
$ok = @proc_terminate($this->process, $signal);
13961400
} elseif (function_exists('posix_kill')) {
1397-
$ok = @posix_kill($this->getPid(), $signal);
1398-
} elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $this->getPid()), array(2 => array('pipe', 'w')), $pipes)) {
1401+
$ok = @posix_kill($pid, $signal);
1402+
} elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), array(2 => array('pipe', 'w')), $pipes)) {
13991403
$ok = false === fgets($pipes[2]);
14001404
}
14011405
if (!$ok) {

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -769,22 +769,16 @@ public function testRestart()
769769
*/
770770
public function testRunProcessWithTimeout()
771771
{
772-
$timeout = 0.1;
773-
$process = $this->getProcess(self::$phpBin.' -r "sleep(1);"');
774-
$process->setTimeout($timeout);
772+
$process = $this->getProcess(self::$phpBin.' -r "sleep(30);"');
773+
$process->setTimeout(0.1);
775774
$start = microtime(true);
776775
try {
777776
$process->run();
778777
$this->fail('A RuntimeException should have been raised');
779778
} catch (RuntimeException $e) {
780779
}
781-
$duration = microtime(true) - $start;
782780

783-
if ('\\' !== DIRECTORY_SEPARATOR) {
784-
// On Windows, timers are too transient
785-
$maxDuration = $timeout + 2 * Process::TIMEOUT_PRECISION;
786-
$this->assertLessThan($maxDuration, $duration);
787-
}
781+
$this->assertLessThan(15, microtime(true) - $start);
788782

789783
throw $e;
790784
}

src/Symfony/Component/Yaml/Parser.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,6 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
238238
if ($isRef) {
239239
$this->refs[$isRef] = $data[$key];
240240
}
241-
242-
if ($objectForMap && !is_object($data)) {
243-
$data = (object) $data;
244-
}
245241
} else {
246242
// multiple documents are not supported
247243
if ('---' === $this->currentLine) {
@@ -305,6 +301,10 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
305301
mb_internal_encoding($mbEncoding);
306302
}
307303

304+
if ($objectForMap && !is_object($data)) {
305+
$data = (object) $data;
306+
}
307+
308308
return empty($data) ? null : $data;
309309
}
310310

src/Symfony/Component/Yaml/Tests/ParserTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,15 @@ public function testObjectForMapEnabledWithInlineMapping()
460460
$this->assertEquals('cat', $result->fiz);
461461
}
462462

463+
public function testObjectForMapIsAppliedAfterParsing()
464+
{
465+
$expected = new \stdClass();
466+
$expected->foo = 'bar';
467+
$expected->baz = 'foobar';
468+
469+
$this->assertEquals($expected, $this->parser->parse("foo: bar\nbaz: foobar", false, false, true));
470+
}
471+
463472
/**
464473
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
465474
*/

0 commit comments

Comments
 (0)
0