8000 Merge branch '3.4' · symfony/symfony@14de848 · GitHub
[go: up one dir, main page]

Skip to content

Commit 14de848

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 1f574b0 + d484f72 commit 14de848

File tree

50 files changed

+1908
-356
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1908
-356
lines changed

CHANGELOG-3.4.md

Lines changed: 217 additions & 0 deletions
Large diffs are not rendered by default.

UPGRADE-3.4.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ Form
126126
FrameworkBundle
127127
---------------
128128

129+
* The `session.use_strict_mode` option has been deprecated and is enabled by default.
130+
129131
* The `cache:clear` command doesn't clear "app" PSR-6 cache pools anymore,
130132
but still clears "system" ones.
131133
Use the `cache:pool:clear` command to clear "app" pools instead.
@@ -235,18 +237,13 @@ HttpFoundation
235237
* The `Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler`
236238
class has been deprecated and will be removed in 4.0. Use the `\SessionHandler` class instead.
237239

238-
* The `Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy` class has been
239-
deprecated and will be removed in 4.0. Use your `\SessionHandlerInterface` implementation directly.
240+
* The `Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler` class has been
241+
deprecated and will be removed in 4.0. Implement `SessionUpdateTimestampHandlerInterface` or
242+
extend `AbstractSessionHandler` instead.
240243

241244
* The `Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy` class has been
242245
deprecated and will be removed in 4.0. Use your `\SessionHandlerInterface` implementation directly.
243246

244-
* The `Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy` class has been
245-
deprecated and will be removed in 4.0. Use your `\SessionHandlerInterface` implementation directly.
246-
247-
* `NativeSessionStorage::setSaveHandler()` now takes an instance of `\SessionHandlerInterface` as argument.
248-
Not passing it is deprecated and will throw a `TypeError` in 4.0.
249-
250247
* Using `Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler` with the legacy mongo extension
251248
has been deprecated and will be removed in 4.0. Use it with the mongodb/mongodb package and ext-mongodb instead.
252249

UPGRADE-4.0.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ Form
329329
FrameworkBundle
330330
---------------
331331

332+
* The `session.use_strict_mode` option has been removed and strict mode is always enabled.
333+
332334
* The `validator.mapping.cache.doctrine.apc` service has been removed.
333335

334336
* The "framework.trusted_proxies" configuration option and the corresponding "kernel.trusted_proxies" parameter have been removed. Use the `Request::setTrustedProxies()` method in your front controller instead.
@@ -542,12 +544,11 @@ HttpFoundation
542544
* The ability to check only for cacheable HTTP methods using `Request::isMethodSafe()` is
543545
not supported anymore, use `Request::isMethodCacheable()` instead.
544546

545-
* The `Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler`,
546-
`Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy`,
547-
`Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy` and
548-
`Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy` classes have been removed.
547+
* The `Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler` class has been
548+
removed. Implement `SessionUpdateTimestampHandlerInterface` or extend `AbstractSessionHandler` instead.
549549

550-
* `NativeSessionStorage::setSaveHandler()` now requires an instance of `\SessionHandlerInterface` as argument.
550+
* The `Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler` and
551+
`Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy` classes have been removed.
551552

552553
* The `Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler` does not work with the legacy
553554
mongo extension anymore. It requires mongodb/mongodb package and ext-mongodb.

src/Symfony/Bundle/FrameworkBundle/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`
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 <fabien@symfony.com>
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 <ryan@knpuniversity.com>
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+
}

src/Symfony/Bundle/FrameworkBundle/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()

src/Symfony/Bundle/FrameworkBundle/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']);

src/Symfony/Bundle/FrameworkBundle/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>

src/Symfony/Bundle/FrameworkBundle/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" />

src/Symfony/Bundle/FrameworkBundle/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>

src/Symfony/Bundle/FrameworkBundle/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 <fabien@symfony.com>
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+
}

src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<argument type="service" id="event_dispatcher" />
5353
</call>
5454
</service>
55+
<service id="Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface" alias="security.authentication.manager" />
5556

5657
<service id="security.authentication.trust_resolver" class="Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver& 10000 quot;>
5758
<argument>%security.authentication.trust_resolver.anonymous_class%</argument>

src/Symfony/Component/Console/Logger/ConsoleLogger.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,23 @@ public function hasErrored()
121121
*/
122122
private function interpolate($message, array $context)
123123
{
124-
// build a replacement array with braces around the context keys
125-
$replace = array();
124+
if (false === strpos($message, '{')) {
125+
return $message;
126+
}
127+
128+
$replacements = array();
126129
foreach ($context as $key => $val) {
127-
if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) {
128-
$replace[sprintf('{%s}', $key)] = $val;
130+
if (null === $val || is_scalar($val) || (\is_object($val) && method_exists($val, '__toString'))) {
131+
$replacements["{{$key}}"] = $val;
132+
} elseif ($val instanceof \DateTimeInterface) {
133+
$replacements["{{$key}}"] = $val->format(\DateTime::RFC3339);
134+
} elseif (\is_object($val)) {
135+
$replacements["{{$key}}"] = '[object '.\get_class($val).']';
136+
} else {
137+
$replacements["{{$key}}"] = '['.\gettype($val).']';
129138
}
130139
}
131140

132-
// interpolate replacement values into the message and return
133-
return strtr($message, $replace);
141+
return strtr($message, $replacements);
134142
}
135143
}

src/Symfony/Component/Console/Tests/Logger/ConsoleLoggerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,7 @@ public function testObjectCastToString()
166166
} else {
167167
$dummy = $this->getMock('Symfony\Component\Console\Tests\Logger\DummyTest', array('__toString'));
168168
}
169-
$dummy->expects($this->once())
170-
->method('__toString')
171-
->will($this->returnValue('DUMMY'));
169+
$dummy->method('__toString')->will($this->returnValue('DUMMY'));
172170

173171
$this->getLogger()->warning($dummy);
174172

src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ protected function processValue($value, $isRoot = false)
6767
$value->setArguments($this->processValue($value->getArguments()));
6868
$value->setProperties($this->processValue($value->getProperties()));
6969
$value->setMethodCalls($this->processValue($value->getMethodCalls()));
70-
$value->setBindings($this->processValue($value->getBindings()));
7170

7271
$changes = $value->getChanges();
7372
if (isset($changes['factory'])) {

0 commit comments

Comments
 (0)
0