Skip to content

Commit 97704cd

Browse files
Merge branch '3.4'
* 3.4: bumped Symfony version to 3.4.0 updated VERSION for 3.4.0-BETA1 updated CHANGELOG for 3.4.0-BETA1 Do not process bindings in AbstractRecursivePass don't bind scalar values to controller method arguments Add extra autowiring aliases adding AdapterInterface alias for cache.app Adding a new debug:autowiring command [HttpFoundation] Make sessions secure and lazy [Routing] Ensure uniqueness without repeated check [Console] Sync ConsoleLogger::interpolate with the one in HttpKernel
2 parents e1e8212 + 3a8a4c9 commit 97704cd

File tree

9 files changed

+177
-15
lines changed

9 files changed

+177
-15
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ CHANGELOG
2222
* Removed the "framework.validation.cache" configuration option. Configure the "cache.validator" service under "framework.cache.pools" instead.
2323
* Removed `PhpStringTokenParser`, use `Symfony\Component\Translation\Extractor\PhpStringTokenParser` instead.
2424
* Removed `PhpExtractor`, use `Symfony\Component\Translation\Extractor\PhpExtractor` instead.
25+
* Removed the `use_strict_mode` session option, it's is now enabled by default
2526

2627
3.4.0
2728
-----
2829

30+
* Session `use_strict_mode` is now enabled by default and the corresponding option has been deprecated
2931
* Made the `cache:clear` command to *not* clear "app" PSR-6 cache pools anymore,
3032
but to still clear "system" ones; use the `cache:pool:clear` command to clear "app" pools instead
3133
* Always register a minimalist logger that writes in `stderr`

Command/DebugAutowiringCommand.php

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Command;
13+
14+
use Symfony\Component\Console\Input\InputArgument;
15+
use Symfony\Component\Console\Input\InputInterface;
16+
use Symfony\Component\Console\Output\OutputInterface;
17+
use Symfony\Component\Console\Style\SymfonyStyle;
18+
19+
/**
20+
* A console command for autowiring information.
21+
*
22+
* @author Ryan Weaver <[email protected]>
23+
*
24+
* @internal
25+
*/
26+
class DebugAutowiringCommand extends ContainerDebugCommand
27+
{
28+
protected static $defaultName = 'debug:autowiring';
29+
30+
/**
31+
* {@inheritdoc}
32+
*/
33+
protected function configure()
34+
{
35+
$this
36+
->setDefinition(array(
37+
new InputArgument('search', InputArgument::OPTIONAL, 'A search filter'),
38+
))
39+
->setDescription('Lists classes/interfaces you can use for autowiring')
40+
->setHelp(<<<'EOF'
41+
The <info>%command.name%</info> command displays all classes and interfaces that
42+
you can use as type-hints for autowiring:
43+
44+
<info>php %command.full_name%</info>
45+
46+
You can also pass a search term to filter the list:
47+
48+
<info>php %command.full_name% log</info>
49+
50+
EOF
51+
)
52+
;
53+
}
54+
55+
/**
56+
* {@inheritdoc}
57+
*/
58+
protected function execute(InputInterface $input, OutputInterface $output)
59+
{
60+
$io = new SymfonyStyle($input, $output);
61+
$errorIo = $io->getErrorStyle();
62+
63+
$builder = $this->getContainerBuilder();
64+
$serviceIds = $builder->getServiceIds();
65+
$serviceIds = array_filter($serviceIds, array($this, 'filterToServiceTypes'));
66+
67+
if ($search = $input->getArgument('search')) {
68+
$serviceIds = array_filter($serviceIds, function ($serviceId) use ($search) {
69+
return false !== stripos($serviceId, $search);
70+
});
71+
72+
if (empty($serviceIds)) {
73+
$errorIo->error(sprintf('No autowirable classes or interfaces found matching "%s"', $search));
74+
75+
return 1;
76+
}
77+
}
78+
79+
asort($serviceIds);
80+
81+
$io->title('Autowirable Services');
82+
$io->text('The following classes & interfaces can be used as type-hints when autowiring:');
83+
if ($search) {
84+
$io->text(sprintf('(only showing classes/interfaces matching <comment>%s</comment>)', $search));
85+
}
86+
$io->newLine();
87+
$tableRows = array();
88+
foreach ($serviceIds as $serviceId) {
89+
$tableRows[] = array(sprintf('<fg=cyan>%s</fg=cyan>', $serviceId));
90+
if ($builder->hasAlias($serviceId)) {
91+
$tableRows[] = array(sprintf(' alias to %s', $builder->getAlias($serviceId)));
92+
}
93+
}
94+
95+
$io->table(array(), $tableRows);
96+
}
97+
}

DependencyInjection/Configuration.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,10 @@ private function addSessionSection(ArrayNodeDefinition $rootNode)
413413
->scalarNode('gc_divisor')->end()
414414
->scalarNode('gc_probability')->defaultValue(1)->end()
415415
->scalarNode('gc_maxlifetime')->end()
416-
->booleanNode('use_strict_mode')->end()
417416
->scalarNode('save_path')->defaultValue('%kernel.cache_dir%/sessions')->end()
418417
->integerNode('metadata_update_threshold')
419418
->defaultValue('0')
420-
->info('seconds to wait between 2 session metadata updates, it will also prevent the session handler to write if the session has not changed')
419+
->info('seconds to wait between 2 session metadata updates')
421420
->end()
422421
->end()
423422
->end()

DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c
728728
// session storage
729729
$container->setAlias('session.storage', $config['storage_id'])->setPrivate(true);
730730
$options = array();
731-
foreach (array('name', 'cookie_lifetime', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'use_cookies', 'gc_maxlifetime', 'gc_probability', 'gc_divisor', 'use_strict_mode') as $key) {
731+
foreach (array('name', 'cookie_lifetime', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'use_cookies', 'gc_maxlifetime', 'gc_probability', 'gc_divisor') as $key) {
732732
if (isset($config[$key])) {
733733
$options[$key] = $config[$key];
734734
}
@@ -742,14 +742,7 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c
742742
$container->getDefinition('session.storage.native')->replaceArgument(1, null);
743743
$container->getDefinition('session.storage.php_bridge')->replaceArgument(0, null);
744744
} else {
745-
$handlerId = $config['handler_id'];
746-
747-
if ($config['metadata_update_threshold'] > 0) {
748-
$container->getDefinition('session.handler.write_check')->addArgument(new Reference($handlerId));
749-
$handlerId = 'session.handler.write_check';
750-
}
751-
752-
$container->setAlias('session.handler', $handlerId)->setPrivate(true);
745+
$container->setAlias('session.handler', $config['handler_id'])->setPrivate(true);
753746
}
754747

755748
$container->setParameter('session.save_path', $config['save_path']);

Resources/config/cache.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,6 @@
111111
<service id="cache.global_clearer" parent="cache.default_clearer" public="true" />
112112
<service id="cache.app_clearer" alias="cache.default_clearer" public="true" />
113113
<service id="Psr\Cache\CacheItemPoolInterface" alias="cache.app" />
114+
<service id="Symfony\Component\Cache\Adapter\AdapterInterface" alias="cache.app" />
114115
</services>
115116
</container>

Resources/config/console.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
<tag name="console.command" command="debug:container" />
5656
</service>
5757

58+
<service id="Symfony\Bundle\FrameworkBundle\Command\DebugAutowiringCommand">
59+
<tag name="console.command" command="debug:autowiring" />
60+
</service>
61+
5862
<service id="Symfony\Bundle\FrameworkBundle\Command\EventDispatcherDebugCommand">
5963
<argument type="service" id="event_dispatcher" />
6064
<tag name="console.command" command="debug:event-dispatcher" />

Resources/config/routing.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
<service id="Symfony\Component\Routing\RouterInterface" alias="router" />
7878
<service id="Symfony\Component\Routing\Generator\UrlGeneratorInterface" alias="router" />
7979
<service id="Symfony\Component\Routing\Matcher\UrlMatcherInterface" alias="router" />
80+
<service id="Symfony\Component\Routing\RequestContextAwareInterface" alias="router" />
8081

8182
<service id="router.request_context" class="Symfony\Component\Routing\RequestContext">
8283
<argument>%router.request_context.base_url%</argument>

Resources/config/session.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@
4848
<argument type="service" id="session.storage.metadata_bag" />
4949
</service>
5050

51-
<service id="session.handler.native_file" class="Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler">
52-
<argument>%session.save_path%</argument>
51+
<service id="session.handler.native_file" class="Symfony\Component\HttpFoundation\Session\Storage\Handler\StrictSessionHandler">
52+
<argument type="service">
53+
<service class="Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler">
54+
<argument>%session.save_path%</argument>
55+
</service>
56+
</argument>
5357
</service>
5458

55-
<service id="session.handler.write_check" class="Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler" />
56-
5759
<service id="session_listener" class="Symfony\Component\HttpKernel\EventListener\SessionListener">
5860
<tag name="kernel.event_subscriber" />
5961
<argument type="service">
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
13+
14+
use Symfony\Bundle\FrameworkBundle\Console\Application;
15+
use Symfony\Component\Console\Tester\ApplicationTester;
16+
17+
/**
18+
* @group functional
19+
*/
20+
class DebugAutowiringCommandTest extends WebTestCase
21+
{
22+
public function testBasicFunctionality()
23+
{
24+
static::bootKernel(array('test_case' => 'ContainerDebug', 'root_config' => 'config.yml'));
25+
26+
$application = new Application(static::$kernel);
27+
$application->setAutoExit(false);
28+
29+
$tester = new ApplicationTester($application);
30+
$tester->run(array('command' => 'debug:autowiring'));
31+
32+
$this->assertContains('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
33+
$this->assertContains('alias to http_kernel', $tester->getDisplay());
34+
}
35+
36+
public function testSearchArgument()
37+
{
38+
static::bootKernel(array('test_case' => 'ContainerDebug', 'root_config' => 'config.yml'));
39+
40+
$application = new Application(static::$kernel);
41+
$application->setAutoExit(false);
42+
43+
$tester = new ApplicationTester($application);
44+
$tester->run(array('command' => 'debug:autowiring', 'search' => 'kern'));
45+
46+
$this->assertContains('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
47+
$this->assertNotContains('Symfony\Component\Routing\RouterInterface', $tester->getDisplay());
48+
}
49+
50+
public function testSearchNoResults()
51+
{
52+
static::bootKernel(array('test_case' => 'ContainerDebug', 'root_config' => 'config.yml'));
53+
54+
$application = new Application(static::$kernel);
55+
$application->setAutoExit(false);
56+
57+
$tester = new ApplicationTester($application);
58+
$tester->run(array('command' => 'debug:autowiring', 'search' => 'foo_fake'), array('capture_stderr_separately' => true));
59+
60+
$this->assertContains('No autowirable classes or interfaces found matching "foo_fake"', $tester->getErrorOutput());
61+
$this->assertEquals(1, $tester->getStatusCode());
62+
}
63+
}

0 commit comments

Comments
 (0)