Skip to content

Commit a4cc3d6

Browse files
committed
remove deprecated features
1 parent ddd6e69 commit a4cc3d6

File tree

14 files changed

+96
-212
lines changed

14 files changed

+96
-212
lines changed

src/Symfony/Bundle/SecurityBundle/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ CHANGELOG
1414
* removed command `init:acl` along with `InitAclCommand` class
1515
* removed `acl` configuration key and related services, use symfony/acl-bundle instead
1616
* removed auto picking the first registered provider when no configured provider on a firewall and ambiguous
17+
* The firewall option `logout_on_user_change` is now always true, which will trigger a logout if the user changes
18+
between requests.
1719

1820
3.4.0
1921
-----

src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
202202
->booleanNode('stateless')->defaultFalse()->end()
203203
->scalarNode('context')->cannotBeEmpty()->end()
204204
->booleanNode('logout_on_user_change')
205-
->defaultFalse()
205+
->defaultTrue()
206206
->info('When true, it will trigger a logout for the user if something has changed. This will be the default behavior as of Syfmony 4.0.')
207207
->end()
208208
->arrayNode('logout')

src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,6 @@ private function createFirewalls($config, ContainerBuilder $container)
188188
$customUserChecker = true;
189189
}
190190

191-
if (!isset($firewall['logout_on_user_change']) || !$firewall['logout_on_user_change']) {
192-
@trigger_error('Setting logout_on_user_change to false is deprecated as of 3.4 and will always be true in 4.0. Set logout_on_user_change to true in your firewall configuration.', E_USER_DEPRECATED);
193-
}
194-
195191
$contextListenerDefinition->addMethodCall('setLogoutOnUserChange', array($firewall['logout_on_user_change']));
196192

197193
$configId = 'security.firewall.map.config.'.$name;

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -123,82 +123,6 @@ public function testDisableRoleHierarchyVoter()
123123
$this->assertFalse($container->hasDefinition('security.access.role_hierarchy_voter'));
124124
}
125125

126-
/**
127-
* @group legacy
128-
* @expectedDeprecation Setting logout_on_user_change to false is deprecated as of 3.4 and will always be true in 4.0. Set logout_on_user_change to true in your firewall configuration.
129-
*/
130-
public function testDeprecationForUserLogout()
131-
{
132-
$container = $this->getRawContainer();
133-
134-
$container->loadFromExtension('security', array(
135-
'providers' => array(
136-
'default' => array('id' => 'foo'),
137-
),
138-
139-
'firewalls' => array(
140-
'some_firewall' => array(
141-
'pattern' => '/.*',
142-
'http_basic' => null,
143-
'logout_on_user_change' => false,
144-
),
145-
),
146-
));
147-
148-
$container->compile();
149-
}
150-
151-
/**
152-
* @group legacy
153-
* @expectedDeprecation Firewall "some_firewall" is configured as "stateless" but the "switch_user.stateless" key is set to false. Both should have the same value, the firewall's "stateless" value will be used as default value for the "switch_user.stateless" key in 4.0.
154-
*/
155-
public function testSwitchUserNotStatelessOnStatelessFirewall()
156-
{
157-
$container = $this->getRawContainer();
158-
159-
$container->loadFromExtension('security', array(
160-
'providers' => array(
161-
'default' => array('id' => 'foo'),
162-
),
163-
164-
'firewalls' => array(
165-
'some_firewall' => array(
166-
'stateless' => true,
167-
'http_basic' => null,
168-
'switch_user' => array('stateless' => false),
169-
'logout_on_user_change' => true,
170-
),
171-
),
172-
));
173-
174-
$container->compile();
175-
}
176-
177-
/**
178-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
179-
* @expectedExceptionMessage Not configuring explicitly the provider on "default" firewall is ambiguous as there is more than one registered provider.
180-
*/
181-
public function testDeprecationForAmbiguousProvider()
182-
{
183-
$container = $this->getRawContainer();
184-
185-
$container->loadFromExtension('security', array(
186-
'providers' => array(
187-
'first' => array('id' => 'foo'),
188-
'second' => array('id' => 'bar'),
189-
),
190-
191-
'firewalls' => array(
192-
'default' => array(
193-
'http_basic' => null,
194-
'logout_on_user_change' => true,
195-
),
196-
),
197-
));
198-
199-
$container->compile();
200-
}
201-
202126
protected function getRawContainer()
203127
{
204128
$container = new ContainerBuilder();

src/Symfony/Component/DependencyInjection/CHANGELOG.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,49 @@ CHANGELOG
44
4.0.0
55
-----
66

7+
* Relying on service auto-registration while autowiring is not supported anymore.
8+
Explicitly inject your dependencies or create services whose ids are
9+
their fully-qualified class name.
10+
11+
Before:
12+
13+
```php
14+
namespace App\Controller;
15+
16+
use App\Mailer;
17+
18+
class DefaultController
19+
{
20+
public function __construct(Mailer $mailer) {
21+
// ...
22+
}
23+
24+
// ...
25+
}
26+
```
27+
```yml
28+
services:
29+
App\Controller\DefaultController:
30+
autowire: true
31+
```
32+
33+
After:
34+
35+
```php
36+
// same PHP code
37+
```
38+
```yml
39+
services:
40+
App\Controller\DefaultController:
41+
autowire: true
42+
43+
# or
44+
# App\Controller\DefaultController:
45+
# arguments: { $mailer: "@App\Mailer" }
46+
47+
App\Mailer:
48+
autowire: true
49+
```
750
* removed autowiring services based on the types they implement
851
* added a third `$methodName` argument to the `getProxyFactoryCode()` method
952
of the `DumperInterface`

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

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,6 @@ private function getAutowiredReference(TypedReference $reference, $deprecationMe
253253
if (isset($this->autowired[$type])) {
254254
return $this->autowired[$type] ? new TypedReference($this->autowired[$type], $type) : null;
255255
}
256-
257-
return $this->createAutowiredDefinition($type);
258256
}
259257

260258
/**
@@ -325,49 +323,6 @@ private function set($type, $id)
325323
$this->ambiguousServiceTypes[$type][] = $id;
326324
}
327325

328-
/**
329-
* Registers a definition for the type if possible or throws an exception.
330-
*
331-
* @param string $type
332-
*
333-
* @return TypedReference|null A reference to the registered definition
334-
*/
335-
private function createAutowiredDefinition($type)
336-
{
337-
if (!($typeHint = $this->container->getReflectionClass($type, false)) || !$typeHint->isInstantiable()) {
338-
return;
339-
}
340-
341-
$currentId = $this->currentId;
342-
$this->currentId = $type;
343-
$this->autowired[$type] = $argumentId = sprintf('autowired.%s', $type);
344-
$argumentDefinition = new Definition($type);
345-
$argumentDefinition->setPublic(false);
346-
$argumentDefinition->setAutowired(true);
347-
348-
try {
349-
$originalThrowSetting = $this->throwOnAutowiringException;
350-
$this->throwOnAutowiringException = true;
351-
$this->processValue($argumentDefinition, true);
352-
$this->container->setDefinition($argumentId, $argumentDefinition);
353-
} catch (AutowiringFailedException $e) {
354-
$this->autowired[$type] = false;
355-
$this->lastFailure = $e->getMessage();
356-
$this->container->log($this, $this->lastFailure);
357-
358-
return;
359-
} finally {
360-
$this->throwOnAutowiringException = $originalThrowSetting;
361-
$this->currentId = $currentId;
362-
}
363-
364-
@trigger_error(sprintf('Relying on service auto-registration for type "%s" is deprecated since version 3.4 and won\'t be supported in 4.0. Create a service named "%s" instead.', $type, $type), E_USER_DEPRECATED);
365-
366-
$this->container->log($this, sprintf('Type "%s" has been auto-registered for service "%s".', $type, $this->currentId));
367-
368-
return new TypedReference($argumentId, $type);
369-
}
370-
371326
private function createTypeNotFoundMessage(TypedReference $reference, $label)
372327
{
373328
if (!$r = $this->container->getReflectionClass($type = $reference->getType(), false)) {

src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,10 @@ public function testWithTypeSet()
247247
}
248248

249249
/**
250-
* @group legacy
251-
* @expectedDeprecation Relying on service auto-registration for type "Symfony\Component\DependencyInjection\Tests\Compiler\Lille" is deprecated since version 3.4 and won't be supported in 4.0. Create a service named "Symfony\Component\DependencyInjection\Tests\Compiler\Lille" instead.
252-
* @expectedDeprecation Relying on service auto-registration for type "Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas" is deprecated since version 3.4 and won't be supported in 4.0. Create a service named "Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas" instead.
250+
* @expectedException \Symfony\Component\DependencyInjection\Exception\AutowiringFailedException
251+
* @expectedExceptionMessage Cannot autowire service "coop_tilleuls": argument "$j" of method "Symfony\Component\DependencyInjection\Tests\Compiler\LesTilleuls::__construct()" references class "Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas" but no such service exists.
253252
*/
254-
public function testCreateDefinition()
253+
public function testServicesAreNotAutoCreated()
255254
{
256255
$container = new ContainerBuilder();
257256

@@ -260,19 +259,6 @@ public function testCreateDefinition()
260259

261260
$pass = new AutowirePass();
262261
$pass->process($container);
263-
264-
$this->assertCount(2, $container->getDefinition('coop_tilleuls')->getArguments());
265-
$this->assertEquals('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas', $container->getDefinition('coop_tilleuls')->getArgument(0));
266-
$this->assertEquals('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas', $container->getDefinition('coop_tilleuls')->getArgument(1));
267-
268-
$dunglasDefinition = $container->getDefinition('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Dunglas');
269-
$this->assertEquals(__NAMESPACE__.'\Dunglas', $dunglasDefinition->getClass());
270-
$this->assertFalse($dunglasDefinition->isPublic());
271-
$this->assertCount(1, $dunglasDefinition->getArguments());
272-
$this->assertEquals('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Lille', $dunglasDefinition->getArgument(0));
273-
274-
$lilleDefinition = $container->getDefinition('autowired.Symfony\Component\DependencyInjection\Tests\Compiler\Lille');
275-
$this->assertEquals(__NAMESPACE__.'\Lille', $lilleDefinition->getClass());
276262
}
277263

278264
public function testResolveParameter()
@@ -563,25 +549,6 @@ public function testExplicitMethodInjection()
563549
);
564550
}
565551

566-
/**
567-
* @group legacy
568-
* @expectedDeprecation Relying on service auto-registration for type "Symfony\Component\DependencyInjection\Tests\Compiler\A" is deprecated since version 3.4 and won't be supported in 4.0. Create a service named "Symfony\Component\DependencyInjection\Tests\Compiler\A" instead.
569-
*/
570-
public function testTypedReference()
571-
{
572-
$container = new ContainerBuilder();
573-
574-
$container
575-
->register('bar', Bar::class)
576-
->setProperty('a', array(new TypedReference(A::class, A::class, Bar::class)))
577-
;
578-
579-
$pass = new AutowirePass();
580-
$pass->process($container);
581-
582-
$this->assertSame(A::class, $container->getDefinition('autowired.'.A::class)->getClass());
583-
}
584-
585552
public function getCreateResourceTests()
586553
{
587554
return array(

src/Symfony/Component/Filesystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
-----
66

77
* removed `LockHandler`
8+
* Support for passing relative paths to `Filesystem::makePathRelative()` has been removed.
89

910
3.3.0
1011
-----
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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\Component\Filesystem\Exception;
13+
14+
/**
15+
* @author Christian Flothmann <christian.flothmann@sensiolabs.de>
16+
*/
17+
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
18+
{
19+
}

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Filesystem;
1313

14+
use Symfony\Component\Filesystem\Exception\InvalidArgumentException;
1415
use Symfony\Component\Filesystem\Exception\IOException;
1516
use Symfony\Component\Filesystem\Exception\FileNotFoundException;
1617

@@ -450,8 +451,12 @@ public function readlink($path, $canonicalize = false)
450451
*/
451452
public function makePathRelative($endPath, $startPath)
452453
{
453-
if (!$this->isAbsolutePath($endPath) || !$this->isAbsolutePath($startPath)) {
454-
@trigger_error(sprintf('Support for passing relative paths to %s() is deprecated since version 3.4 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
454+
if (!$this->isAbsolutePath($startPath)) {
455+
throw new InvalidArgumentException(sprintf('The start path "%s" is not absolute.', $startPath));
456+
}
457+
458+
if (!$this->isAbsolutePath($endPath)) {
459+
throw new InvalidArgumentException(sprintf('The end path "%s" is not absolute.', $endPath));
455460
}
456461

457462
// Normalize separators on Windows

0 commit comments

Comments
 (0)