Merge branch '2.8' into 3.0
* 2.8: Set the redraw frequency at least to 1. Setting it to 0 would otherwise produce an error. [Process] Unset callback after stop to free memory Improve error message for undefined DIC aliases [VarDumper] fixed .sf-dump z-index [Validator] Updated Luxembourgish translations for 2.8 Disallow http-kernel 3.x, fixes #16837. [DependencyInjection] Validate class names and factory methods ampq → amqp Fix typo Refactoring EntityUserProvider::__construct() to not do work, cause cache warm error [Form] Add context to FormFactory deprecations CS: remove unneeded parentheses around control statements [TwigBridge] Clean deps now that 2.8.0 is tagged
This commit is contained in:
commit
e0eb6d467f
@ -55,7 +55,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface
|
||||
*/
|
||||
public function getEntitiesByIds($identifier, array $values)
|
||||
{
|
||||
$qb = clone ($this->queryBuilder);
|
||||
$qb = clone $this->queryBuilder;
|
||||
$alias = current($qb->getRootAliases());
|
||||
$parameter = 'ORMQueryBuilderLoader_getEntitiesByIds_'.$identifier;
|
||||
$where = $qb->expr()->in($alias.'.'.$identifier, ':'.$parameter);
|
||||
|
@ -27,22 +27,17 @@ use Symfony\Component\Security\Core\User\UserInterface;
|
||||
*/
|
||||
class EntityUserProvider implements UserProviderInterface
|
||||
{
|
||||
private $registry;
|
||||
private $managerName;
|
||||
private $classOrAlias;
|
||||
private $class;
|
||||
private $repository;
|
||||
private $property;
|
||||
private $metadata;
|
||||
|
||||
public function __construct(ManagerRegistry $registry, $class, $property = null, $managerName = null)
|
||||
public function __construct(ManagerRegistry $registry, $classOrAlias, $property = null, $managerName = null)
|
||||
{
|
||||
$em = $registry->getManager($managerName);
|
||||
$this->class = $class;
|
||||
$this->metadata = $em->getClassMetadata($class);
|
||||
|
||||
if (false !== strpos($this->class, ':')) {
|
||||
$this->class = $this->metadata->getName();
|
||||
}
|
||||
|
||||
$this->repository = $em->getRepository($class);
|
||||
$this->registry = $registry;
|
||||
$this->managerName = $managerName;
|
||||
$this->classOrAlias = $classOrAlias;
|
||||
$this->property = $property;
|
||||
}
|
||||
|
||||
@ -51,14 +46,15 @@ class EntityUserProvider implements UserProviderInterface
|
||||
*/
|
||||
public function loadUserByUsername($username)
|
||||
{
|
||||
$repository = $this->getRepository();
|
||||
if (null !== $this->property) {
|
||||
$user = $this->repository->findOneBy(array($this->property => $username));
|
||||
$user = $repository->findOneBy(array($this->property => $username));
|
||||
} else {
|
||||
if (!$this->repository instanceof UserLoaderInterface) {
|
||||
throw new \InvalidArgumentException(sprintf('The Doctrine repository "%s" must implement Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface.', get_class($this->repository)));
|
||||
if (!$repository instanceof UserLoaderInterface) {
|
||||
throw new \InvalidArgumentException(sprintf('The Doctrine repository "%s" must implement Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface.', get_class($repository)));
|
||||
}
|
||||
|
||||
$user = $this->repository->loadUserByUsername($username);
|
||||
$user = $repository->loadUserByUsername($username);
|
||||
}
|
||||
|
||||
if (null === $user) {
|
||||
@ -73,18 +69,20 @@ class EntityUserProvider implements UserProviderInterface
|
||||
*/
|
||||
public function refreshUser(UserInterface $user)
|
||||
{
|
||||
if (!$user instanceof $this->class) {
|
||||
$class = $this->getClass();
|
||||
if (!$user instanceof $class) {
|
||||
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
|
||||
}
|
||||
|
||||
if ($this->repository instanceof UserProviderInterface) {
|
||||
$refreshedUser = $this->repository->refreshUser($user);
|
||||
$repository = $this->getRepository();
|
||||
if ($repository instanceof UserProviderInterface) {
|
||||
$refreshedUser = $repository->refreshUser($user);
|
||||
} else {
|
||||
// The user must be reloaded via the primary key as all other data
|
||||
// might have changed without proper persistence in the database.
|
||||
// That's the case when the user has been changed by a form with
|
||||
// validation errors.
|
||||
if (!$id = $this->metadata->getIdentifierValues($user)) {
|
||||
if (!$id = $this->getClassMetadata()->getIdentifierValues($user)) {
|
||||
throw new \InvalidArgumentException('You cannot refresh a user '.
|
||||
'from the EntityUserProvider that does not contain an identifier. '.
|
||||
'The user object has to be serialized with its own identifier '.
|
||||
@ -92,7 +90,7 @@ class EntityUserProvider implements UserProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
$refreshedUser = $this->repository->find($id);
|
||||
$refreshedUser = $repository->find($id);
|
||||
if (null === $refreshedUser) {
|
||||
throw new UsernameNotFoundException(sprintf('User with id %s not found', json_encode($id)));
|
||||
}
|
||||
@ -106,6 +104,36 @@ class EntityUserProvider implements UserProviderInterface
|
||||
*/
|
||||
public function supportsClass($class)
|
||||
{
|
||||
return $class === $this->class || is_subclass_of($class, $this->class);
|
||||
return $class === $this->getClass() || is_subclass_of($class, $this->getClass());
|
||||
}
|
||||
|
||||
private function getObjectManager()
|
||||
{
|
||||
return $this->registry->getManager($this->managerName);
|
||||
}
|
||||
|
||||
private function getRepository()
|
||||
{
|
||||
return $this->getObjectManager()->getRepository($this->classOrAlias);
|
||||
}
|
||||
|
||||
private function getClass()
|
||||
{
|
||||
if (null === $this->class) {
|
||||
$class = $this->classOrAlias;
|
||||
|
||||
if (false !== strpos($class, ':')) {
|
||||
$class = $this->getClassMetadata()->getName();
|
||||
}
|
||||
|
||||
$this->class = $class;
|
||||
}
|
||||
|
||||
return $this->class;
|
||||
}
|
||||
|
||||
private function getClassMetadata()
|
||||
{
|
||||
return $this->getObjectManager()->getClassMetadata($this->classOrAlias);
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ class EntityUserProviderTest extends \PHPUnit_Framework_TestCase
|
||||
private function getManager($em, $name = null)
|
||||
{
|
||||
$manager = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
|
||||
$manager->expects($this->once())
|
||||
$manager->expects($this->any())
|
||||
->method('getManager')
|
||||
->with($this->equalTo($name))
|
||||
->will($this->returnValue($em));
|
||||
|
@ -22,7 +22,7 @@
|
||||
"require-dev": {
|
||||
"symfony/asset": "~2.8|~3.0",
|
||||
"symfony/finder": "~2.8|~3.0",
|
||||
"symfony/form": "~2.8,>2.8-BETA1|~3.0,>3.0-BETA1",
|
||||
"symfony/form": "~2.8|~3.0",
|
||||
"symfony/http-kernel": "~2.8|~3.0",
|
||||
"symfony/polyfill-intl-icu": "~1.0",
|
||||
"symfony/routing": "~2.8|~3.0",
|
||||
|
@ -68,10 +68,8 @@ class ProgressBar
|
||||
// disable overwrite when output does not support ANSI codes.
|
||||
$this->overwrite = false;
|
||||
|
||||
if ($this->max > 10) {
|
||||
// set a reasonable redraw frequency so output isn't flooded
|
||||
$this->setRedrawFrequency($max / 10);
|
||||
}
|
||||
// set a reasonable redraw frequency so output isn't flooded
|
||||
$this->setRedrawFrequency($max / 10);
|
||||
}
|
||||
|
||||
$this->startTime = time();
|
||||
@ -301,11 +299,11 @@ class ProgressBar
|
||||
/**
|
||||
* Sets the redraw frequency.
|
||||
*
|
||||
* @param int $freq The frequency in steps
|
||||
* @param int|float $freq The frequency in steps
|
||||
*/
|
||||
public function setRedrawFrequency($freq)
|
||||
{
|
||||
$this->redrawFreq = (int) $freq;
|
||||
$this->redrawFreq = max((int) $freq, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -296,7 +296,7 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testRedrawFrequency()
|
||||
{
|
||||
$bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($output = $this->getOutputStream(), 6));
|
||||
$bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($this->getOutputStream(), 6));
|
||||
$bar->expects($this->exactly(4))->method('display');
|
||||
|
||||
$bar->setRedrawFrequency(2);
|
||||
@ -307,6 +307,26 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
|
||||
$bar->advance(1);
|
||||
}
|
||||
|
||||
public function testRedrawFrequencyIsAtLeastOneIfZeroGiven()
|
||||
{
|
||||
$bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($this->getOutputStream()));
|
||||
|
||||
$bar->expects($this->exactly(2))->method('display');
|
||||
$bar->setRedrawFrequency(0);
|
||||
$bar->start();
|
||||
$bar->advance();
|
||||
}
|
||||
|
||||
public function testRedrawFrequencyIsAtLeastOneIfSmallerOneGiven()
|
||||
{
|
||||
$bar = $this->getMock('Symfony\Component\Console\Helper\ProgressBar', array('display'), array($this->getOutputStream()));
|
||||
|
||||
$bar->expects($this->exactly(2))->method('display');
|
||||
$bar->setRedrawFrequency(0.9);
|
||||
$bar->start();
|
||||
$bar->advance();
|
||||
}
|
||||
|
||||
public function testMultiByteSupport()
|
||||
{
|
||||
$bar = new ProgressBar($output = $this->getOutputStream());
|
||||
|
@ -45,7 +45,7 @@ class ReplaceAliasByActualDefinitionPass implements CompilerPassInterface
|
||||
try {
|
||||
$definition = $container->getDefinition($aliasId);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
throw new InvalidArgumentException(sprintf('Unable to replace alias "%s" with "%s".', $alias, $id), null, $e);
|
||||
throw new InvalidArgumentException(sprintf('Unable to replace alias "%s" with actual definition "%s".', $id, $alias), null, $e);
|
||||
}
|
||||
|
||||
if ($definition->isPublic()) {
|
||||
|
@ -689,6 +689,10 @@ EOF;
|
||||
if (null !== $definition->getFactory()) {
|
||||
$callable = $definition->getFactory();
|
||||
if (is_array($callable)) {
|
||||
if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $callable[1])) {
|
||||
throw new RuntimeException(sprintf('Cannot dump definition because of invalid factory method (%s)', $callable[1] ?: 'n/a'));
|
||||
}
|
||||
|
||||
if ($callable[0] instanceof Reference
|
||||
|| ($callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0]))) {
|
||||
return sprintf(" $return{$instantiation}%s->%s(%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? implode(', ', $arguments) : '');
|
||||
@ -1201,8 +1205,12 @@ EOF;
|
||||
}
|
||||
|
||||
if (is_array($factory)) {
|
||||
if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $factory[1])) {
|
||||
throw new RuntimeException(sprintf('Cannot dump definition because of invalid factory method (%s)', $factory[1] ?: 'n/a'));
|
||||
}
|
||||
|
||||
if (is_string($factory[0])) {
|
||||
return sprintf('\\%s::%s(%s)', $factory[0], $factory[1], implode(', ', $arguments));
|
||||
return sprintf('%s::%s(%s)', $this->dumpLiteralClass($this->dumpValue($factory[0])), $factory[1], implode(', ', $arguments));
|
||||
}
|
||||
|
||||
if ($factory[0] instanceof Definition) {
|
||||
@ -1221,12 +1229,8 @@ EOF;
|
||||
if (null === $class) {
|
||||
throw new RuntimeException('Cannot dump definitions which have no class nor factory.');
|
||||
}
|
||||
$class = $this->dumpValue($class);
|
||||
if (false !== strpos($class, '$')) {
|
||||
throw new RuntimeException('Cannot dump definitions which have a variable class name.');
|
||||
}
|
||||
|
||||
return sprintf('new \\%s(%s)', substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments));
|
||||
return sprintf('new %s(%s)', $this->dumpLiteralClass($this->dumpValue($class)), implode(', ', $arguments));
|
||||
} elseif ($value instanceof Variable) {
|
||||
return '$'.$value;
|
||||
} elseif ($value instanceof Reference) {
|
||||
@ -1266,9 +1270,18 @@ EOF;
|
||||
* @param string $class
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private function dumpLiteralClass($class)
|
||||
{
|
||||
if (false !== strpos($class, '$')) {
|
||||
throw new RuntimeException('Cannot dump definitions which have a variable class name.');
|
||||
}
|
||||
if (0 !== strpos($class, "'") || !preg_match('/^\'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(\\\{2}[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*\'$/', $class)) {
|
||||
throw new RuntimeException(sprintf('Cannot dump definition because of invalid class name (%s)', $class ?: 'n/a'));
|
||||
}
|
||||
|
||||
return '\\'.substr(str_replace('\\\\', '\\', $class), 1, -1);
|
||||
}
|
||||
|
||||
|
@ -144,6 +144,31 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase
|
||||
$dumper->dump();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInvalidFactories
|
||||
* @expectedException Symfony\Component\DependencyInjection\Exception\RuntimeException
|
||||
* @expectedExceptionMessage Cannot dump definition
|
||||
*/
|
||||
public function testInvalidFactories($factory)
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$def = new Definition('stdClass');
|
||||
$def->setFactory($factory);
|
||||
$container->setDefinition('bar', $def);
|
||||
$dumper = new PhpDumper($container);
|
||||
$dumper->dump();
|
||||
}
|
||||
|
||||
public function provideInvalidFactories()
|
||||
{
|
||||
return array(
|
||||
array(array('', 'method')),
|
||||
array(array('class', '')),
|
||||
array(array('...', 'method')),
|
||||
array(array('class', '...')),
|
||||
);
|
||||
}
|
||||
|
||||
public function testAliases()
|
||||
{
|
||||
$container = include self::$fixturesPath.'/containers/container9.php';
|
||||
|
@ -443,13 +443,13 @@ class Filesystem
|
||||
*/
|
||||
public function isAbsolutePath($file)
|
||||
{
|
||||
return (strspn($file, '/\\', 0, 1)
|
||||
return strspn($file, '/\\', 0, 1)
|
||||
|| (strlen($file) > 3 && ctype_alpha($file[0])
|
||||
&& substr($file, 1, 1) === ':'
|
||||
&& (strspn($file, '/\\', 2, 1))
|
||||
)
|
||||
|| null !== parse_url($file, PHP_URL_SCHEME)
|
||||
);
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,15 +55,15 @@ class SortableIterator implements \IteratorAggregate
|
||||
};
|
||||
} elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
|
||||
$this->sort = function ($a, $b) {
|
||||
return ($a->getATime() - $b->getATime());
|
||||
return $a->getATime() - $b->getATime();
|
||||
};
|
||||
} elseif (self::SORT_BY_CHANGED_TIME === $sort) {
|
||||
$this->sort = function ($a, $b) {
|
||||
return ($a->getCTime() - $b->getCTime());
|
||||
return $a->getCTime() - $b->getCTime();
|
||||
};
|
||||
} elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
|
||||
$this->sort = function ($a, $b) {
|
||||
return ($a->getMTime() - $b->getMTime());
|
||||
return $a->getMTime() - $b->getMTime();
|
||||
};
|
||||
} elseif (is_callable($sort)) {
|
||||
$this->sort = $sort;
|
||||
|
@ -976,7 +976,7 @@ class Response
|
||||
* Sets the Vary header.
|
||||
*
|
||||
* @param string|array $headers
|
||||
* @param bool $replace Whether to replace the actual value of not (true by default)
|
||||
* @param bool $replace Whether to replace the actual value or not (true by default)
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
|
@ -47,7 +47,7 @@ abstract class AbstractProxy
|
||||
*/
|
||||
public function isSessionHandlerInterface()
|
||||
{
|
||||
return ($this instanceof \SessionHandlerInterface);
|
||||
return $this instanceof \SessionHandlerInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -212,7 +212,7 @@ class FullTransformer
|
||||
*/
|
||||
public function isQuoteMatch($quoteMatch)
|
||||
{
|
||||
return ("'" === $quoteMatch[0]);
|
||||
return "'" === $quoteMatch[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1370,6 +1370,11 @@ class Process
|
||||
$this->exitcode = 128 + $this->processInformation['termsig'];
|
||||
}
|
||||
|
||||
// Free memory from self-reference callback created by buildCallback
|
||||
// Doing so in other contexts like __destruct or by garbage collector is ineffective
|
||||
// Now pipes are closed, so the callback is no longer necessary
|
||||
$this->callback = null;
|
||||
|
||||
return $this->exitcode;
|
||||
}
|
||||
|
||||
|
@ -24,11 +24,11 @@
|
||||
</trans-unit>
|
||||
<trans-unit id="6">
|
||||
<source>You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices.</source>
|
||||
<target>Dir sollt mindestens {{ limit }} Méiglechkeete wielen.</target>
|
||||
<target>Et muss mindestens {{ limit }} Méiglechkeet ausgewielt ginn.|Et musse mindestens {{ limit }} Méiglechkeeten ausgewielt ginn.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="7">
|
||||
<source>You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices.</source>
|
||||
<target>Dir sollt héchstens {{ limit }} Méiglechkeete wielen.</target>
|
||||
<target>Et dierf héchstens {{ limit }} Méiglechkeet ausgewielt ginn.|Et dierfen héchstens {{ limit }} Méiglechkeeten ausgewielt ginn.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="8">
|
||||
<source>One or more of the given values is invalid.</source>
|
||||
@ -298,6 +298,22 @@
|
||||
<source>The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.</source>
|
||||
<target>D'Bild ass am Héichformat ({{ width }}x{{ height }}px). Biller am Héichformat sinn net erlaabt.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="78">
|
||||
<source>An empty file is not allowed.</source>
|
||||
<target>En eidele Fichier ass net erlaabt.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="79">
|
||||
<source>The host could not be resolved.</source>
|
||||
<target>Den Domain-Numm konnt net opgeléist ginn.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="80">
|
||||
<source>This value does not match the expected {{ charset }} charset.</source>
|
||||
<target>Dëse Wäert entsprécht net dem erwaarten Zeechesaz {{ charset }}.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="81">
|
||||
<source>This is not a valid Business Identifier Code (BIC).</source>
|
||||
<target>Dëst ass kee gëltege "Business Identifier Code" (BIC).</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
@ -48,7 +48,7 @@ class AmqpCaster
|
||||
{
|
||||
$prefix = Caster::PREFIX_VIRTUAL;
|
||||
|
||||
// BC layer in the ampq lib
|
||||
// BC layer in the amqp lib
|
||||
if (method_exists($c, 'getReadTimeout')) {
|
||||
$timeout = $c->getReadTimeout();
|
||||
} else {
|
||||
|
@ -31,7 +31,7 @@ class HtmlDumper extends CliDumper
|
||||
protected $headerIsDumped = false;
|
||||
protected $lastDepth = -1;
|
||||
protected $styles = array(
|
||||
'default' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:100000; word-break: normal',
|
||||
'default' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: normal',
|
||||
'num' => 'font-weight:bold; color:#1299DA',
|
||||
'const' => 'font-weight:bold',
|
||||
'str' => 'font-weight:bold; color:#56DB3A',
|
||||
|
@ -712,6 +712,6 @@ class Parser
|
||||
*/
|
||||
private function isStringUnIndentedCollectionItem()
|
||||
{
|
||||
return (0 === strpos($this->currentLine, '- '));
|
||||
return 0 === strpos($this->currentLine, '- ');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user