Skip to content

Commit 649e2cd

Browse files
committed
Merge branch '3.2' into 3.3
* 3.2: [Security] Fix wrong term in UserProviderInterface [HttpFoundation] Set meta refresh time to 0 in RedirectResponse content disable inlining deprecated services [Cache] add constructor docblocks for clarity [Security] validate empty passwords again [DI] Remove irrelevant comment from container [TwigBridge] cleaner implementation of the TwigRenderer
2 parents 80efd8f + d3ca508 commit 649e2cd

File tree

16 files changed

+135
-23
lines changed

16 files changed

+135
-23
lines changed

src/Symfony/Bridge/Twig/Form/TwigRenderer.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,26 @@
2020
*/
2121
class TwigRenderer extends FormRenderer implements TwigRendererInterface
2222
{
23-
/**
24-
* @var TwigRendererEngineInterface
25-
*/
26-
private $engine;
27-
2823
public function __construct(TwigRendererEngineInterface $engine, CsrfTokenManagerInterface $csrfTokenManager = null)
2924
{
3025
parent::__construct($engine, $csrfTokenManager);
26+
}
3127

32-
$this->engine = $engine;
28+
/**
29+
* Returns the engine used by this renderer.
30+
*
31+
* @return TwigRendererEngineInterface The renderer engine
32+
*/
33+
public function getEngine()
34+
{
35+
return parent::getEngine();
3336
}
3437

3538
/**
3639
* {@inheritdoc}
3740
*/
3841
public function setEnvironment(Environment $environment)
3942
{
40-
$this->engine->setEnvironment($environment);
43+
$this->getEngine()->setEnvironment($environment);
4144
}
4245
}

src/Symfony/Component/Cache/Adapter/AbstractAdapter.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface
3232
private $createCacheItem;
3333
private $mergeByLifetime;
3434

35+
/**
36+
* @var int|null The maximum length to enforce for identifiers or null when no limit applies
37+
*/
38+
protected $maxIdLength;
39+
40+
/**
41+
* @param string $namespace
42+
* @param int $defaultLifetime
43+
*/
3544
protected function __construct($namespace = '', $defaultLifetime = 0)
3645
{
3746
$this->namespace = '' === $namespace ? '' : $this->getId($namespace).':';
@@ -74,6 +83,15 @@ function ($deferred, $namespace, &$expiredIds) {
7483
);
7584
}
7685

86+
/**
87+
* @param string $namespace
88+
* @param int $defaultLifetime
89+
* @param string $version
90+
* @param string $directory
91+
* @param LoggerInterface|null $logger
92+
*
93+
* @return AdapterInterface
94+
*/
7795
public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null)
7896
{
7997
if (null === self::$apcuSupported) {

src/Symfony/Component/Cache/Adapter/ApcuAdapter.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ class ApcuAdapter extends AbstractAdapter
1717
{
1818
use ApcuTrait;
1919

20+
/**
21+
* @param string $namespace
22+
* @param int $defaultLifetime
23+
* @param string|null $version
24+
*
25+
* @throws CacheException if APCu is not enabled
26+
*/
2027
public function __construct($namespace = '', $defaultLifetime = 0, $version = null)
2128
{
2229
$this->init($namespace, $defaultLifetime, $version);

src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ class DoctrineAdapter extends AbstractAdapter
1818
{
1919
use DoctrineTrait;
2020

21+
/**
22+
* @param CacheProvider $provider
23+
* @param string $namespace
24+
* @param int $defaultLifetime
25+
*/
2126
public function __construct(CacheProvider $provider, $namespace = '', $defaultLifetime = 0)
2227
{
2328
parent::__construct('', $defaultLifetime);

src/Symfony/Component/Cache/Adapter/FilesystemAdapter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ class FilesystemAdapter extends AbstractAdapter
1717
{
1818
use FilesystemTrait;
1919

20+
/**
21+
* @param string $namespace
22+
* @param int $defaultLifetime
23+
* @param string|null $directory
24+
*/
2025
public function __construct($namespace = '', $defaultLifetime = 0, $directory = null)
2126
{
2227
parent::__construct('', $defaultLifetime);

src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ class PhpFilesAdapter extends AbstractAdapter
1818
{
1919
use PhpFilesTrait;
2020

21+
/**
22+
* @param string $namespace
23+
* @param int $defaultLifetime
24+
* @param string|null $directory
25+
*
26+
* @throws CacheException if OPcache is not enabled
27+
*/
2128
public function __construct($namespace = '', $defaultLifetime = 0, $directory = null)
2229
{
2330
if (!static::isSupported()) {

src/Symfony/Component/Cache/Adapter/ProxyAdapter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ class ProxyAdapter implements AdapterInterface
2626
private $createCacheItem;
2727
private $poolHash;
2828

29+
/**
30+
* @param CacheItemPoolInterface $pool
31+
* @param string $namespace
32+
* @param int $defaultLifetime
33+
*/
2934
public function __construct(CacheItemPoolInterface $pool, $namespace = '', $defaultLifetime = 0)
3035
{
3136
$this->pool = $pool;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private function isInlineableDefinition($id, Definition $definition, ServiceRefe
8282
return true;
8383
}
8484

85-
if ($definition->isPublic() || $definition->isLazy()) {
85+
if ($definition->isDeprecated() || $definition->isPublic() || $definition->isLazy()) {
8686
return false;
8787
}
8888

src/Symfony/Component/DependencyInjection/Container.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@
2828
*
2929
* Parameter and service keys are case insensitive.
3030
*
31-
* A service id can contain lowercased letters, digits, underscores, and dots.
32-
* Underscores are used to separate words, and dots to group services
33-
* under namespaces:
34-
*
35-
* <ul>
36-
* <li>request</li>
37-
* <li>mysql_session_storage</li>
38-
* <li>symfony.mysql_session_storage</li>
39-
* </ul>
40-
*
4131
* A service can also be defined by creating a method named
4232
* getXXXService(), where XXX is the camelized version of the id:
4333
*

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,27 @@ public function testRegisterForAutoconfiguration()
10821082
// when called multiple times, the same instance is returned
10831083
$this->assertSame($childDefA, $container->registerForAutoconfiguration('AInterface'));
10841084
}
1085+
1086+
/**
1087+
* This test checks the trigger of a deprecation note and should not be removed in major releases.
1088+
*
1089+
* @group legacy
1090+
* @expectedDeprecation The "foo" service is deprecated. You should stop using it, as it will soon be removed.
1091+
*/
1092+
public function testPrivateServiceTriggersDeprecation()
1093+
{
1094+
$container = new ContainerBuilder();
1095+
$container->register('foo', 'stdClass')
1096+
->setPublic(false)
1097+
->setDeprecated(true);
1098+
$container->register('bar', 'stdClass')
1099+
->setPublic(true)
1100+
->setProperty('foo', new Reference('foo'));
1101+
1102+
$container->compile();
1103+
1104+
$container->get('bar');
1105+
}
10851106
}
10861107

10871108
class FooClass

src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ public function testGetLegacyServiceIds()
165165
public function testSet()
166166
{
167167
$sc = new Container();
168-
$sc->set('foo', $foo = new \stdClass());
169-
$this->assertSame($foo, $sc->get('foo'), '->set() sets a service');
168+
$sc->set('._. \\o/', $foo = new \stdClass());
169+
$this->assertSame($foo, $sc->get('._. \\o/'), '->set() sets a service');
170170
}
171171

172172
public function testSetWithNullResetTheService()

src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,4 +598,30 @@ public function testDumpHandlesLiteralClassWithRootNamespace()
598598

599599
$this->assertInstanceOf('stdClass', $container->get('foo'));
600600
}
601+
602+
/**
603+
* This test checks the trigger of a deprecation note and should not be removed in major releases.
604+
*
605+
* @group legacy
606+
* @expectedDeprecation The "foo" service is deprecated. You should stop using it, as it will soon be removed.
607+
*/
608+
public function testPrivateServiceTriggersDeprecation()
609+
{
610+
$container = new ContainerBuilder();
611+
$container->register('foo', 'stdClass')
612+
->setPublic(false)
613+
->setDeprecated(true);
614+
$container->register('bar', 'stdClass')
615+
->setPublic(true)
616+
->setProperty('foo', new Reference('foo'));
617+
618+
$container->compile();
619+
620+
$dumper = new PhpDumper($container);
621+
eval('?>'.$dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Private_Service_Triggers_Deprecation')));
622+
623+
$container = new \Symfony_DI_PhpDumper_Test_Private_Service_Triggers_Deprecation();
624+
625+
$container->get('bar');
626+
}
601627
}

src/Symfony/Component/HttpFoundation/RedirectResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function setTargetUrl($url)
8787
<html>
8888
<head>
8989
<meta charset="UTF-8" />
90-
<meta http-equiv="refresh" content="1;url=%1$s" />
90+
<meta http-equiv="refresh" content="0;url=%1$s" />
9191
9292
<title>Redirecting to %1$s</title>
9393
</head>

src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,29 @@ public function testPasswordIsNotValid()
9090
->assertRaised();
9191
}
9292

93+
/**
94+
* @dataProvider emptyPasswordData
95+
*/
96+
public function testEmptyPasswordsAreNotValid($password)
97+
{
98+
$constraint = new UserPassword(array(
99+
'message' => 'myMessage',
100+
));
101+
102+
$this->validator->validate($password, $constraint);
103+
104+
$this->buildViolation('myMessage')
105+
->assertRaised();
106+
}
107+
108+
public function emptyPasswordData()
109+
{
110+
return array(
111+
array(null),
112+
array(''),
113+
);
114+
}
115+
93116
/**
94117
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
95118
*/

src/Symfony/Component/Security/Core/User/UserProviderInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ interface UserProviderInterface
4848
public function loadUserByUsername($username);
4949

5050
/**
51-
* Refreshes the user for the account interface.
51+
* Refreshes the user.
5252
*
5353
* It is up to the implementation to decide if the user data should be
5454
* totally reloaded (e.g. from the database), or if the UserInterface
@@ -59,7 +59,7 @@ public function loadUserByUsername($username);
5959
*
6060
* @return UserInterface
6161
*
62-
* @throws UnsupportedUserException if the account is not supported
62+
* @throws UnsupportedUserException if the user is not supported
6363
*/
6464
public function refreshUser(UserInterface $user);
6565

src/Symfony/Component/Security/Core/Validator/Constraints/UserPasswordValidator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public function validate($password, Constraint $constraint)
4040
}
4141

4242
if (null === $password || '' === $password) {
43+
$this->context->addViolation($constraint->message);
44+
4345
return;
4446
}
4547

0 commit comments

Comments
 (0)