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
This commit is contained in:
commit
649e2cd8bb
@ -20,16 +20,19 @@ use Twig\Environment;
|
||||
*/
|
||||
class TwigRenderer extends FormRenderer implements TwigRendererInterface
|
||||
{
|
||||
/**
|
||||
* @var TwigRendererEngineInterface
|
||||
*/
|
||||
private $engine;
|
||||
|
||||
public function __construct(TwigRendererEngineInterface $engine, CsrfTokenManagerInterface $csrfTokenManager = null)
|
||||
{
|
||||
parent::__construct($engine, $csrfTokenManager);
|
||||
}
|
||||
|
||||
$this->engine = $engine;
|
||||
/**
|
||||
* Returns the engine used by this renderer.
|
||||
*
|
||||
* @return TwigRendererEngineInterface The renderer engine
|
||||
*/
|
||||
public function getEngine()
|
||||
{
|
||||
return parent::getEngine();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -37,6 +40,6 @@ class TwigRenderer extends FormRenderer implements TwigRendererInterface
|
||||
*/
|
||||
public function setEnvironment(Environment $environment)
|
||||
{
|
||||
$this->engine->setEnvironment($environment);
|
||||
$this->getEngine()->setEnvironment($environment);
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,15 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface
|
||||
private $createCacheItem;
|
||||
private $mergeByLifetime;
|
||||
|
||||
/**
|
||||
* @var int|null The maximum length to enforce for identifiers or null when no limit applies
|
||||
*/
|
||||
protected $maxIdLength;
|
||||
|
||||
/**
|
||||
* @param string $namespace
|
||||
* @param int $defaultLifetime
|
||||
*/
|
||||
protected function __construct($namespace = '', $defaultLifetime = 0)
|
||||
{
|
||||
$this->namespace = '' === $namespace ? '' : $this->getId($namespace).':';
|
||||
@ -74,6 +83,15 @@ abstract class AbstractAdapter implements AdapterInterface, LoggerAwareInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $namespace
|
||||
* @param int $defaultLifetime
|
||||
* @param string $version
|
||||
* @param string $directory
|
||||
* @param LoggerInterface|null $logger
|
||||
*
|
||||
* @return AdapterInterface
|
||||
*/
|
||||
public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null)
|
||||
{
|
||||
if (null === self::$apcuSupported) {
|
||||
|
@ -17,6 +17,13 @@ class ApcuAdapter extends AbstractAdapter
|
||||
{
|
||||
use ApcuTrait;
|
||||
|
||||
/**
|
||||
* @param string $namespace
|
||||
* @param int $defaultLifetime
|
||||
* @param string|null $version
|
||||
*
|
||||
* @throws CacheException if APCu is not enabled
|
||||
*/
|
||||
public function __construct($namespace = '', $defaultLifetime = 0, $version = null)
|
||||
{
|
||||
$this->init($namespace, $defaultLifetime, $version);
|
||||
|
@ -18,6 +18,11 @@ class DoctrineAdapter extends AbstractAdapter
|
||||
{
|
||||
use DoctrineTrait;
|
||||
|
||||
/**
|
||||
* @param CacheProvider $provider
|
||||
* @param string $namespace
|
||||
* @param int $defaultLifetime
|
||||
*/
|
||||
public function __construct(CacheProvider $provider, $namespace = '', $defaultLifetime = 0)
|
||||
{
|
||||
parent::__construct('', $defaultLifetime);
|
||||
|
@ -17,6 +17,11 @@ class FilesystemAdapter extends AbstractAdapter
|
||||
{
|
||||
use FilesystemTrait;
|
||||
|
||||
/**
|
||||
* @param string $namespace
|
||||
* @param int $defaultLifetime
|
||||
* @param string|null $directory
|
||||
*/
|
||||
public function __construct($namespace = '', $defaultLifetime = 0, $directory = null)
|
||||
{
|
||||
parent::__construct('', $defaultLifetime);
|
||||
|
@ -18,6 +18,13 @@ class PhpFilesAdapter extends AbstractAdapter
|
||||
{
|
||||
use PhpFilesTrait;
|
||||
|
||||
/**
|
||||
* @param string $namespace
|
||||
* @param int $defaultLifetime
|
||||
* @param string|null $directory
|
||||
*
|
||||
* @throws CacheException if OPcache is not enabled
|
||||
*/
|
||||
public function __construct($namespace = '', $defaultLifetime = 0, $directory = null)
|
||||
{
|
||||
if (!static::isSupported()) {
|
||||
|
@ -26,6 +26,11 @@ class ProxyAdapter implements AdapterInterface
|
||||
private $createCacheItem;
|
||||
private $poolHash;
|
||||
|
||||
/**
|
||||
* @param CacheItemPoolInterface $pool
|
||||
* @param string $namespace
|
||||
* @param int $defaultLifetime
|
||||
*/
|
||||
public function __construct(CacheItemPoolInterface $pool, $namespace = '', $defaultLifetime = 0)
|
||||
{
|
||||
$this->pool = $pool;
|
||||
|
@ -82,7 +82,7 @@ class InlineServiceDefinitionsPass extends AbstractRecursivePass implements Repe
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($definition->isPublic() || $definition->isLazy()) {
|
||||
if ($definition->isDeprecated() || $definition->isPublic() || $definition->isLazy()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -28,16 +28,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
|
||||
*
|
||||
* Parameter and service keys are case insensitive.
|
||||
*
|
||||
* A service id can contain lowercased letters, digits, underscores, and dots.
|
||||
* Underscores are used to separate words, and dots to group services
|
||||
* under namespaces:
|
||||
*
|
||||
* <ul>
|
||||
* <li>request</li>
|
||||
* <li>mysql_session_storage</li>
|
||||
* <li>symfony.mysql_session_storage</li>
|
||||
* </ul>
|
||||
*
|
||||
* A service can also be defined by creating a method named
|
||||
* getXXXService(), where XXX is the camelized version of the id:
|
||||
*
|
||||
|
@ -1082,6 +1082,27 @@ class ContainerBuilderTest extends TestCase
|
||||
// when called multiple times, the same instance is returned
|
||||
$this->assertSame($childDefA, $container->registerForAutoconfiguration('AInterface'));
|
||||
}
|
||||
|
||||
/**
|
||||
* This test checks the trigger of a deprecation note and should not be removed in major releases.
|
||||
*
|
||||
* @group legacy
|
||||
* @expectedDeprecation The "foo" service is deprecated. You should stop using it, as it will soon be removed.
|
||||
*/
|
||||
public function testPrivateServiceTriggersDeprecation()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('foo', 'stdClass')
|
||||
->setPublic(false)
|
||||
->setDeprecated(true);
|
||||
$container->register('bar', 'stdClass')
|
||||
->setPublic(true)
|
||||
->setProperty('foo', new Reference('foo'));
|
||||
|
||||
$container->compile();
|
||||
|
||||
$container->get('bar');
|
||||
}
|
||||
}
|
||||
|
||||
class FooClass
|
||||
|
@ -165,8 +165,8 @@ class ContainerTest extends TestCase
|
||||
public function testSet()
|
||||
{
|
||||
$sc = new Container();
|
||||
$sc->set('foo', $foo = new \stdClass());
|
||||
$this->assertSame($foo, $sc->get('foo'), '->set() sets a service');
|
||||
$sc->set('._. \\o/', $foo = new \stdClass());
|
||||
$this->assertSame($foo, $sc->get('._. \\o/'), '->set() sets a service');
|
||||
}
|
||||
|
||||
public function testSetWithNullResetTheService()
|
||||
|
@ -598,4 +598,30 @@ class PhpDumperTest extends TestCase
|
||||
|
||||
$this->assertInstanceOf('stdClass', $container->get('foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* This test checks the trigger of a deprecation note and should not be removed in major releases.
|
||||
*
|
||||
* @group legacy
|
||||
* @expectedDeprecation The "foo" service is deprecated. You should stop using it, as it will soon be removed.
|
||||
*/
|
||||
public function testPrivateServiceTriggersDeprecation()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('foo', 'stdClass')
|
||||
->setPublic(false)
|
||||
->setDeprecated(true);
|
||||
$container->register('bar', 'stdClass')
|
||||
->setPublic(true)
|
||||
->setProperty('foo', new Reference('foo'));
|
||||
|
||||
$container->compile();
|
||||
|
||||
$dumper = new PhpDumper($container);
|
||||
eval('?>'.$dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Private_Service_Triggers_Deprecation')));
|
||||
|
||||
$container = new \Symfony_DI_PhpDumper_Test_Private_Service_Triggers_Deprecation();
|
||||
|
||||
$container->get('bar');
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ class RedirectResponse extends Response
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="refresh" content="1;url=%1$s" />
|
||||
<meta http-equiv="refresh" content="0;url=%1$s" />
|
||||
|
||||
<title>Redirecting to %1$s</title>
|
||||
</head>
|
||||
|
@ -90,6 +90,29 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider emptyPasswordData
|
||||
*/
|
||||
public function testEmptyPasswordsAreNotValid($password)
|
||||
{
|
||||
$constraint = new UserPassword(array(
|
||||
'message' => 'myMessage',
|
||||
));
|
||||
|
||||
$this->validator->validate($password, $constraint);
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function emptyPasswordData()
|
||||
{
|
||||
return array(
|
||||
array(null),
|
||||
array(''),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
|
||||
*/
|
||||
|
@ -48,7 +48,7 @@ interface UserProviderInterface
|
||||
public function loadUserByUsername($username);
|
||||
|
||||
/**
|
||||
* Refreshes the user for the account interface.
|
||||
* Refreshes the user.
|
||||
*
|
||||
* It is up to the implementation to decide if the user data should be
|
||||
* totally reloaded (e.g. from the database), or if the UserInterface
|
||||
@ -59,7 +59,7 @@ interface UserProviderInterface
|
||||
*
|
||||
* @return UserInterface
|
||||
*
|
||||
* @throws UnsupportedUserException if the account is not supported
|
||||
* @throws UnsupportedUserException if the user is not supported
|
||||
*/
|
||||
public function refreshUser(UserInterface $user);
|
||||
|
||||
|
@ -40,6 +40,8 @@ class UserPasswordValidator extends ConstraintValidator
|
||||
}
|
||||
|
||||
if (null === $password || '' === $password) {
|
||||
$this->context->addViolation($constraint->message);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user