Skip to content

Commit deaf53c

Browse files
committed
Merge branch '4.1'
* 4.1: [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 3afe4e7 + 46fff8b commit deaf53c

File tree

20 files changed

+155
-74
lines changed

20 files changed

+155
-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/Component/Cache/Traits/AbstractTrait.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,7 @@ public function clear()
107107
{
108108
$this->deferred = array();
109109
if ($cleared = $this->versioningIsEnabled) {
110-
$namespaceVersion = 2;
111-
try {
112-
foreach ($this->doFetch(array('/'.$this->namespace)) as $v) {
113-
$namespaceVersion = 1 + (int) $v;
114-
}
115-
} catch (\Exception $e) {
116-
}
117-
$namespaceVersion .= '/';
110+
$namespaceVersion = substr_replace(base64_encode(pack('V', mt_rand())), ':', 5);
118111
try {
119112
$cleared = $this->doSave(array('/'.$this->namespace => $namespaceVersion), 0);
120113
} catch (\Exception $e) {
@@ -254,6 +247,10 @@ private function getId($key)
254247
foreach ($this->doFetch(array('/'.$this->namespace)) as $v) {
255248
$this->namespaceVersion = $v;
256249
}
250+
if ('1:' === $this->namespaceVersion) {
251+
$this->namespaceVersion = substr_replace(base64_encode(pack('V', time())), ':', 5);
252+
$this->doSave(array('@'.$this->namespace => $this->namespaceVersion), 0);
253+
}
257254
} catch (\Exception $e) {
258255
}
259256
}

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
@@ -985,6 +985,31 @@ public function testRunReturnsIntegerExitCode()
985985
$this->assertSame(4, $exitCode, '->run() returns integer exit code extracted from raised exception');
986986
}
987987

988+
public function testRunDispatchesIntegerExitCode()
989+
{
990+
$passedRightValue = false;
991+
992+
// We can assume here that some other test asserts that the event is dispatched at all
993+
$dispatcher = new EventDispatcher();
994+
$self = $this;
995+
$dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($self, &$passedRightValue) {
996+
$passedRightValue = (4 === $event->getExitCode());
997+
});
998+
999+
$application = new Application();
1000+
$application->setDispatcher($dispatcher);
1001+
$application->setAutoExit(false);
1002+
1003+
$application->register('test')->setCode(function (InputInterface $input, OutputInterface $output) {
1004+
throw new \Exception('', 4);
1005+
});
1006+
1007+
$tester = new ApplicationTester($application);
1008+
$tester->run(array('command' => 'test'));
1009+
1010+
$this->assertTrue($passedRightValue, '-> exit code 4 was passed in the console.terminate event');
1011+
}
1012+
9881013
public function testRunReturnsExitCodeOneForExceptionCodeZero()
9891014
{
9901015
$exception = new \Exception('', 0);
@@ -1000,6 +1025,31 @@ public function testRunReturnsExitCodeOneForExceptionCodeZero()
10001025
$this->assertSame(1, $exitCode, '->run() returns exit code 1 when exception code is 0');
10011026
}
10021027

1028+
public function testRunDispatchesExitCodeOneForExceptionCodeZero()
1029+
{
1030+
$passedRightValue = false;
1031+
1032+
// We can assume here that some other test asserts that the event is dispatched at all
1033+
$dispatcher = new EventDispatcher();
1034+
$self = $this;
1035+
$dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($self, &$passedRightValue) {
1036+
$passedRightValue = (1 === $event->getExitCode());
1037+
});
1038+
1039+
$application = new Application();
1040+
$application->setDispatcher($dispatcher);
1041+
$application->setAutoExit(false);
1042+
1043+
$application->register('test')->setCode(function (InputInterface $input, OutputInterface $output) {
1044+
throw new \Exception();
1045+
});
1046+
1047+
$tester = new ApplicationTester($application);
1048+
$tester->run(array('command' => 'test'));
1049+
1050+
$this->assertTrue($passedRightValue, '-> exit code 1 was passed in the console.terminate event');
1051+
}
1052+
10031053
/**
10041054
* @expectedException \LogicException
10051055
* @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
{

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ public function setFormat($format, $mimeTypes)
13321332
* * _format request attribute
13331333
* * $default
13341334
*
1335-
* @param string $default The default format
1335+
* @param string|null $default The default format
13361336
*
13371337
* @return string The request format
13381338
*/

0 commit comments

Comments
 (0)