Skip to content

Commit 46fff8b

Browse files
committed
Merge branch '3.4' into 4.1
* 3.4: [Console] simplified code removed useless phpdoc improve docblocks around group sequences [Cache] prevent getting older entries when the version key is evicted [WebProfilerBundle] added a note in the README [Yaml] Skip parser test with root user [Filesystem] Skip tests on readable file when run with root user [FWBundle] Fix an error in WebTestCase::createClient's PHPDoc [HttpFoundation][Security] forward locale and format to subrequests [Console] Send the right exit code to console.terminate listeners [HttpFoundation] fix hidding warnings from session handlers Caching missed templates on cache warmup
2 parents 0e47775 + 8805cfd commit 46fff8b

File tree

21 files changed

+161
-74
lines changed

21 files changed

+161
-74
lines changed

src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ abstract class WebTestCase extends KernelTestCase
2323
/**
2424
* Creates a Client.
2525
*
26-
* @param array $options An array of options to pass to the createKernel class
26+
* @param array $options An array of options to pass to the createKernel method
2727
* @param array $server An array of server parameters
2828
*
2929
* @return Client A Client instance

src/Symfony/Bundle/TwigBundle/TemplateIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getIterator()
6363
$this->templates = array_merge(
6464
$this->templates,
6565
$this->findTemplatesInDirectory($bundle->getPath().'/Resources/views', $name),
66-
$this->findTemplatesInDirectory($this->rootDir.'/'.$bundle->getName().'/views', $name),
66+
$this->findTemplatesInDirectory($this->rootDir.'/Resources/'.$bundle->getName().'/views', $name),
6767
$this->findTemplatesInDirectory($this->defaultPath.'/bundles/'.$bundle->getName(), $name)
6868
);
6969
}

src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/Resources/BarBundle/views/base.html.twig

Whitespace-only changes.

src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function testGetIterator()
3131
sort($sorted);
3232
$this->assertEquals(
3333
array(
34+
'@Bar/base.html.twig',
3435
'@Bar/index.html.twig',
3536
'@Bar/layout.html.twig',
3637
'@Foo/index.html.twig',

src/Symfony/Bundle/WebProfilerBundle/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
WebProfilerBundle
22
=================
33

4+
The Web profiler bundle is a **development tool** that gives detailed
5+
information about the execution of any request.
6+
7+
**Never** enable it on production servers as it will lead to major security
8+
vulnerabilities in your project.
9+
410
Resources
511
---------
612

src/Symfony/Component/Cache/Traits/AbstractTrait.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,7 @@ public function clear()
106106
{
107107
$this->deferred = array();
108108
if ($cleared = $this->versioningIsEnabled) {
109-
$namespaceVersion = 2;
110-
try {
111-
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
112-
$namespaceVersion = 1 + (int) $v;
113-
}
114-
} catch (\Exception $e) {
115-
}
116-
$namespaceVersion .= ':';
109+
$namespaceVersion = substr_replace(base64_encode(pack('V', mt_rand())), ':', 5);
117110
try {
118111
$cleared = $this->doSave(array('@'.$this->namespace => $namespaceVersion), 0);
119112
} catch (\Exception $e) {
@@ -247,6 +240,10 @@ private function getId($key)
247240
foreach ($this->doFetch(array('@'.$this->namespace)) as $v) {
248241
$this->namespaceVersion = $v;
249242
}
243+
if ('1:' === $this->namespaceVersion) {
244+
$this->namespaceVersion = substr_replace(base64_encode(pack('V', time())), ':', 5);
245+
$this->doSave(array('@'.$this->namespace => $this->namespaceVersion), 0);
246+
}
250247
} catch (\Exception $e) {
251248
}
252249
}

src/Symfony/Component/Console/Application.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ public function run(InputInterface $input = null, OutputInterface $output = null
159159
} else {
160160
$exitCode = 1;
161161
}
162+
163+
return $exitCode;
162164
} finally {
163165
// if the exception handler changed, keep it
164166
// otherwise, unregister $renderException

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,31 @@ public function testRunReturnsIntegerExitCode()
960960
$this->assertSame(4, $exitCode, '->run() returns integer exit code extracted from raised exception');
961961
}
962962

963+
public function testRunDispatchesIntegerExitCode()
964+
{
965+
$passedRightValue = false;
966+
967+
// We can assume here that some other test asserts that the event is dispatched at all
968+
$dispatcher = new EventDispatcher();
969+
$self = $this;
970+
$dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($self, &$passedRightValue) {
971+
$passedRightValue = (4 === $event->getExitCode());
972+
});
973+
974+
$application = new Application();
975+
$application->setDispatcher($dispatcher);
976+
$application->setAutoExit(false);
977+
978+
$application->register('test')->setCode(function (InputInterface $input, OutputInterface $output) {
979+
throw new \Exception('', 4);
980+
});
981+
982+
$tester = new ApplicationTester($application);
983+
$tester->run(array('command' => 'test'));
984+
985+
$this->assertTrue($passedRightValue, '-> exit code 4 was passed in the console.terminate event');
986+
}
987+
963988
public function testRunReturnsExitCodeOneForExceptionCodeZero()
964989
{
965990
$exception = new \Exception('', 0);
@@ -975,6 +1000,31 @@ public function testRunReturnsExitCodeOneForExceptionCodeZero()
9751000
$this->assertSame(1, $exitCode, '->run() returns exit code 1 when exception code is 0');
9761001
}
9771002

1003+
public function testRunDispatchesExitCodeOneForExceptionCodeZero()
1004+
{
1005+
$passedRightValue = false;
1006+
1007+
// We can assume here that some other test asserts that the event is dispatched at all
1008+
$dispatcher = new EventDispatcher();
1009+
$self = $this;
1010+
$dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($self, &$passedRightValue) {
1011+
$passedRightValue = (1 === $event->getExitCode());
1012+
});
1013+
1014+
$application = new Application();
1015+
$application->setDispatcher($dispatcher);
1016+
$application->setAutoExit(false);
1017+
1018+
$application->register('test')->setCode(function (InputInterface $input, OutputInterface $output) {
1019+
throw new \Exception();
1020+
});
1021+
1022+
$tester = new ApplicationTester($application);
1023+
$tester->run(array('command' => 'test'));
1024+
1025+
$this->assertTrue($passedRightValue, '-> exit code 1 was passed in the console.terminate event');
1026+
}
1027+
9781028
/**
9791029
* @expectedException \LogicException
9801030
* @expectedExceptionMessage An option with shortcut "e" already exists.

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ public function testCopyUnreadableFileFails()
5050
$this->markTestSkipped('This test cannot run on Windows.');
5151
}
5252

53+
if (!getenv('USER') || 'root' === getenv('USER')) {
54+
$this->markTestSkipped('This test will fail if run under superuser');
55+
}
56+
5357
$sourceFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_source_file';
5458
$targetFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_target_file';
5559

@@ -124,6 +128,10 @@ public function testCopyWithOverrideWithReadOnlyTargetFails()
124128
$this->markTestSkipped('This test cannot run on Windows.');
125129
}
126130

131+
if (!getenv('USER') || 'root' === getenv('USER')) {
132+
$this->markTestSkipped('This test will fail if run under superuser');
133+
}
134+
127135
$sourceFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_source_file';
128136
$targetFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_target_file';
129137

src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public function validate($form, Constraint $constraint)
137137
/**
138138
* Returns the validation groups of the given form.
139139
*
140-
* @return array The validation groups
140+
* @return string|GroupSequence|(string|GroupSequence)[] The validation groups
141141
*/
142142
private static function getValidationGroups(FormInterface $form)
143143
{
@@ -172,10 +172,10 @@ private static function getValidationGroups(FormInterface $form)
172172
/**
173173
* Post-processes the validation groups option for a given form.
174174
*
175-
* @param array|callable $groups The validation groups
176-
* @param FormInterface $form The validated form
175+
* @param string|GroupSequence|(string|GroupSequence)[]|callable $groups The validation groups
176+
* @param FormInterface $form The validated form
177177
*
178-
* @return array The validation groups
178+
* @return (string|GroupSequence)[] The validation groups
179179
*/
180180
private static function resolveValidationGroups($groups, FormInterface $form)
181181
{

0 commit comments

Comments
 (0)