Skip to content

Commit b1b6860

Browse files
Merge branch '3.3' into 3.4
* 3.3: Revert "bug symfony#24105 [Filesystem] check permissions if dump target dir is missing (xabbuh)" [Filesystem] skip tests if not applicable [Fabbot] Do not run php-cs-fixer if there are no change in src/ [Security] Fix exception when use_referer option is true and referer is not set or empty [HttpKernel] "controller.service_arguments" services should be public Get KERNEL_DIR through $_ENV too for KernelTestCase Get KERNEL_CLASS through $_ENV too check permissions if dump target dir is missing
2 parents 565a1c4 + 483a274 commit b1b6860

File tree

6 files changed

+37
-7
lines changed

6 files changed

+37
-7
lines changed

.php_cs.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php
22

3+
if (!file_exists(__DIR__.'/src')) {
4+
exit(0);
5+
}
6+
37
return PhpCsFixer\Config::create()
48
->setRules(array(
59
'@Symfony' => true,

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ private static function getPhpUnitCliConfigArgument()
114114
*/
115115
protected static function getKernelClass()
116116
{
117-
if (isset($_SERVER['KERNEL_CLASS'])) {
118-
if (!class_exists($class = $_SERVER['KERNEL_CLASS'])) {
117+
if (isset($_SERVER['KERNEL_CLASS']) || isset($_ENV['KERNEL_CLASS'])) {
118+
$class = isset($_SERVER['KERNEL_CLASS']) ? $_SERVER['KERNEL_CLASS'] : $_ENV['KERNEL_CLASS'];
119+
if (!class_exists($class)) {
119120
throw new \RuntimeException(sprintf('Class "%s" doesn\'t exist or cannot be autoloaded. Check that the KERNEL_CLASS value in phpunit.xml matches the fully-qualified class name of your Kernel or override the %s::createKernel() method.', $class, static::class));
120121
}
121122

@@ -124,8 +125,8 @@ protected static function getKernelClass()
124125
@trigger_error(sprintf('Using the KERNEL_DIR environment variable or the automatic guessing based on the phpunit.xml / phpunit.xml.dist file location is deprecated since 3.4. Set the KERNEL_CLASS environment variable to the fully-qualified class name of your Kernel instead. Not setting the KERNEL_CLASS environment variable will throw an exception on 4.0 unless you override the %1$::createKernel() or %1$::getKernelClass() method.', static::class), E_USER_DEPRECATED);
125126
}
126127

127-
if (isset($_SERVER['KERNEL_DIR'])) {
128-
$dir = $_SERVER['KERNEL_DIR'];
128+
if (isset($_SERVER['KERNEL_DIR']) || isset($_ENV['KERNEL_DIR'])) {
129+
$dir = isset($_SERVER['KERNEL_DIR']) ? $_SERVER['KERNEL_DIR'] : $_ENV['KERNEL_DIR'];
129130

130131
if (!is_dir($dir)) {
131132
$phpUnitDir = static::getPhpUnitXmlDir();

src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function process(ContainerBuilder $container)
5151

5252
foreach ($container->findTaggedServiceIds($this->controllerTag, true) as $id => $tags) {
5353
$def = $container->getDefinition($id);
54+
$def->setPublic(true);
5455
$class = $def->getClass();
5556
$autowire = $def->isAutowired();
5657

src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,21 @@ public function testArgumentWithNoTypeHintIsOk()
268268
$this->assertEmpty(array_keys($locator));
269269
}
270270

271+
public function testControllersAreMadePublic()
272+
{
273+
$container = new ContainerBuilder();
274+
$resolver = $container->register('argument_resolver.service')->addArgument(array());
275+
276+
$container->register('foo', ArgumentWithoutTypeController::class)
277+
->setPublic(false)
278+
->addTag('controller.service_arguments');
279+
280+
$pass = new RegisterControllerArgumentLocatorsPass();
281+
$pass->process($container);
282+
283+
$this->assertTrue($container->getDefinition('foo')->isPublic());
284+
}
285+
271286
/**
272287
* @dataProvider provideBindings
273288
*/

src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,11 @@ protected function determineTargetUrl(Request $request)
122122
return $targetUrl;
123123
}
124124

125-
if ($this->options['use_referer']) {
126-
$targetUrl = $request->headers->get('Referer');
125+
if ($this->options['use_referer'] && $targetUrl = $request->headers->get('Referer')) {
127126
if (false !== $pos = strpos($targetUrl, '?')) {
128127
$targetUrl = substr($targetUrl, 0, $pos);
129128
}
130-
if ($targetUrl !== $this->httpUtils->generateUri($request, $this->options['login_path'])) {
129+
if ($targetUrl && $targetUrl !== $this->httpUtils->generateUri($request, $this->options['login_path'])) {
131130
return $targetUrl;
132131
}
133132
}

src/Symfony/Component/Security/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ public function getRequestRedirections()
8383
array(),
8484
'/',
8585
),
86+
'target path as referer when referer not set' => array(
87+
Request::create('/'),
88+
array('use_referer' => true),
89+
'/',
90+
),
91+
'target path as referer when referer is ?' => array(
92+
Request::create('/', 'GET', array(), array(), array(), array('HTTP_REFERER' => '?')),
93+
array('use_referer' => true),
94+
'/',
95+
),
8696
'target path should be different than login URL' => array(
8797
Request::create('/', 'GET', array(), array(), array(), array('HTTP_REFERER' => 'http://localhost/login')),
8898
array('use_referer' => true, 'login_path' => '/login'),

0 commit comments

Comments
 (0)