8000 Merge branch '4.3' into 4.4 · symfony/symfony@a31119b · GitHub
[go: up one dir, main page]

Skip to content

Commit a31119b

Browse files
Merge branch '4.3' into 4.4
* 4.3: Fix merge [DoctrineBridge] try to fix deprecations from doctrine/persistence [DI] Add support for immutable setters in CallTrait [Cache] Propagate expiry when syncing items in ChainAdapter [Routing] fix memoryleak when loading compiled routes [Translation] fix memoryleak in PhpFileLoader
2 parents 25494fa + ad4b5fd commit a31119b

35 files changed

+221
-123
lines changed

src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php

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

1212
namespace Symfony\Bridge\Doctrine\CacheWarmer;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry;
14+
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
15+
use Doctrine\Persistence\ManagerRegistry;
1516
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
1617

1718
/**
@@ -26,7 +27,10 @@ class ProxyCacheWarmer implements CacheWarmerInterface
2627
{
2728
private $registry;
2829

29-
public function __construct(ManagerRegistry $registry)
30+
/**
31+
* @param ManagerRegistry|LegacyManagerRegistry $registry
32+
*/
33+
public function __construct($registry)
3034
{
3135
$this->registry = $registry;
3236
}

src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php

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

1212
namespace Symfony\Bridge\Doctrine\DataCollector;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry;
14+
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
1515
use Doctrine\DBAL\Logging\DebugStack;
1616
use Doctrine\DBAL\Types\ConversionException;
1717
use Doctrine\DBAL\Types\Type;
18+
use Doctrine\Persistence\ManagerRegistry;
1819
use Symfony\Component\HttpFoundation\Request;
1920
use Symfony\Component\HttpFoundation\Response;
2021
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
@@ -37,7 +38,10 @@ class DoctrineDataCollector extends DataCollector
3738
*/
3839
private $loggers = [];
3940

40-
public function __construct(ManagerRegistry $registry)
41+
/**
42+
* @param ManagerRegistry|LegacyManagerRegistry $registry
43+
*/
44+
public function __construct($registry)
4145
{
4246
$this->registry = $registry;
4347
$this->connections = $registry->getConnectionNames();

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function process(ContainerBuilder $container)
143143

144144
$mappingDriverDef = $this->getDriver($container);
145145
$chainDriverDefService = $this->getChainDriverServiceName($container);
146-
// Definition for a Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain
146+
// Definition for a Doctrine\Persistence\Mapping\Driver\MappingDriverChain
147147
$chainDriverDef = $container->getDefinition($chainDriverDefService);
148148
foreach ($this->namespaces as $namespace) {
149149
$chainDriverDef->addMethodCall('addDriver', [$mappingDriverDef, $namespace]);

src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Form\ChoiceList;
1313

14-
use Doctrine\Common\Persistence\ObjectManager;
14+
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
15+
use Doctrine\Persistence\ObjectManager;
1516
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1617
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
1718
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
@@ -40,9 +41,10 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface
4041
* passed which optimizes the object loading for one of the Doctrine
4142
* mapper implementations.
4243
*
43-
* @param string $class The class name of the loaded objects
44+
* @param ObjectManager|LegacyObjectManager $manager The object manager
45+
* @param string $class The class name of the loaded objects
4446
*/
45-
public function __construct(ObjectManager $manager, string $class, IdReader $idReader = null, EntityLoaderInterface $objectLoader = null)
47+
public function __construct($manager, string $class, IdReader $idReader = null, EntityLoaderInterface $objectLoader = null)
4648
{
4749
$classMetadata = $manager->getClassMetadata($class);
4850

src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Form\ChoiceList;
1313

14-
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
15-
use Doctrine\Common\Persistence\ObjectManager;
14+
use Doctrine\Common\Persistence\Mapping\ClassMetadata as LegacyClassMetadata;
15+
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
16+
use Doctrine\Persistence\Mapping\ClassMetadata;
17+
use Doctrine\Persistence\ObjectManager;
1618
use Symfony\Component\Form\Exception\RuntimeException;
1719

1820
/**
@@ -35,7 +37,11 @@ class IdReader
3537
*/
3638
private $associationIdReader;
3739

38-
public function __construct(ObjectManager $om, ClassMetadata $classMetadata)
40+
/**
41+
* @param ObjectManager|LegacyObjectManager $om
42+
* @param ClassMetadata|LegacyClassMetadata $classMetadata
43+
*/
44+
public function __construct($om, $classMetadata)
3945
{
4046
$ids = $classMetadata->getIdentifierFieldNames();
4147
$idType = $classMetadata->getTypeOfField(current($ids));

src/Symfony/Bridge/Doctrine/Form/DoctrineOrmExtension.php

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

1212
namespace Symfony\Bridge\Doctrine\Form;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry;
14+
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
15+
use Doctrine\Persistence\ManagerRegistry;
1516
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
1617
use Symfony\Component\Form\AbstractExtension;
1718

1819
class DoctrineOrmExtension extends AbstractExtension
1920
{
2021
protected $registry;
2122

22-
public function __construct(ManagerRegistry $registry)
23+
/**
24+
* @param ManagerRegistry|LegacyManagerRegistry $registry
25+
*/
26+
public function __construct($registry)
2327
{
2428
$this->registry = $registry;
2529
}

src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Form;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry;
15-
use Doctrine\Common\Persistence\Mapping\MappingException;
14+
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
15+
use Doctrine\Common\Persistence\Mapping\MappingException as LegacyCommonMappingException;
1616
use Doctrine\Common\Persistence\Proxy;
1717
use Doctrine\DBAL\Types\Type;
1818
use Doctrine\ORM\Mapping\ClassMetadataInfo;
1919
use Doctrine\ORM\Mapping\MappingException as LegacyMappingException;
20+
use Doctrine\Persistence\ManagerRegistry;
21+
use Doctrine\Persistence\Mapping\MappingException;
2022
use Symfony\Component\Form\FormTypeGuesserInterface;
2123
use Symfony\Component\Form\Guess\Guess;
2224
use Symfony\Component\Form\Guess\TypeGuess;
@@ -28,7 +30,10 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
2830

2931
private $cache = [];
3032

31-
public function __construct(ManagerRegistry $registry)
33+
/**
34+
* @param ManagerRegistry|LegacyManagerRegistry $registry
35+
*/
36+
public function __construct($registry)
3237
{
3338
$this->registry = $registry;
3439
}
@@ -182,6 +187,8 @@ protected function getMetadata($class)
182187
return $this->cache[$class] = [$em->getClassMetadata($class), $name];
183188
} catch (MappingException $e) {
184189
// not an entity or mapped super class
190+
} catch (LegacyCommonMappingException $e) {
191+
// not an entity or mapped super class
185192
} catch (LegacyMappingException $e) {
186193
// not an entity or mapped super class, using Doctrine ORM 2.2
187194
}
@@ -192,10 +199,12 @@ protected function getMetadata($class)
192199

193200
private static function getRealClass(string $class): string
194201
{
195-
if (false === $pos = strrpos($class, '\\'.Proxy::MARKER.'\\')) {
202+
$marker = interface_exists(Proxy::class) ? '\\'.Proxy::MARKER.'\\' : '\__CG__\\';
203+
204+
if (false === $pos = strrpos($class, $marker)) {
196205
return $class;
197206
}
198207

199-
return substr($class, $pos + Proxy::MARKER_LENGTH + 2);
208+
return substr($class, $pos + \strlen($marker));
200209
}
201210
}

src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
namespace Symfony\Bridge\Doctrine\Form\Type;
1313

1414
use Doctrine\Common\Collections\Collection;
15-
use Doctrine\Common\Persistence\ManagerRegistry;
16-
use Doctrine\Common\Persistence\ObjectManager;
15+
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
16+
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
17+
use Doctrine\Persistence\ManagerRegistry;
18+
use Doctrine\Persistence\ObjectManager;
1719
use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader;
1820
use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface;
1921
use Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader;
@@ -98,7 +100,10 @@ public function getQueryBuilderPartsForCachingHash($queryBuilder): ?array
98100
return null;
99101
}
100102

101-
public function __construct(ManagerRegistry $registry)
103+
/**
104+
* @param ManagerRegistry|LegacyManagerRegistry $registry
105+
*/
106+
public function __construct($registry)
102107
{
103108
$this->registry = $registry;
104109
}
@@ -188,9 +193,8 @@ public function configureOptions(OptionsResolver $resolver)
188193
};
189194

190195
$emNormalizer = function (Options $options, $em) {
191-
/* @var ManagerRegistry $registry */
192196
if (null !== $em) {
193-
if ($em instanceof ObjectManager) {
197+
if ($em instanceof ObjectManager || $em instanceof LegacyObjectManager) {
194198
return $em;
195199
}
196200

@@ -260,7 +264,7 @@ public function configureOptions(OptionsResolver $resolver)
260264
$resolver->setNormalizer('query_builder', $queryBuilderNormalizer);
261265
$resolver->setNormalizer('id_reader', $idReaderNormalizer);
262266

263-
$resolver 10000 ->setAllowedTypes('em', ['null', 'string', 'Doctrine\Common\Persistence\ObjectManager']);
267+
$resolver->setAllowedTypes('em', ['null', 'string', ObjectManager::class, LegacyObjectManager::class]);
264268
}
265269

266270
/**
@@ -271,7 +275,7 @@ public function configureOptions(OptionsResolver $resolver)
271275
*
272276
* @return EntityLoaderInterface
273277
*/
274-
abstract public function getLoader(ObjectManager $manager, $queryBuilder, $class);
278+
abstract public function getLoader(LegacyObjectManager $manager, $queryBuilder, $class);
275279

276280
public function getParent()
277281
{

src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php

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

1212
namespace Symfony\Bridge\Doctrine\Form\Type;
1313

14-
use Doctrine\Common\Persistence\ObjectManager;
14+
use Doctrine\Common\Persistence\ObjectManager as LegacyObjectManager;
1515
use Doctrine\ORM\Query\Parameter;
1616
use Doctrine\ORM\QueryBuilder;
1717
use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader;
@@ -51,7 +51,7 @@ public function configureOptions(OptionsResolver $resolver)
5151
*
5252
* @return ORMQueryBuilderLoader
5353
*/
54-
public function getLoader(ObjectManager $manager, $queryBuilder, $class)
54+
public function getLoader(LegacyObjectManager $manager, $queryBuilder, $class)
5555
{
5656
if (!$queryBuilder instanceof QueryBuilder) {
5757
throw new \TypeError(sprintf('Expected an instance of %s, but got %s.', QueryBuilder::class, \is_object($queryBuilder) ? \get_class($queryBuilder) : \gettype($queryBuilder)));

src/Symfony/Bridge/Doctrine/ManagerRegistry.php

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

1212
namespace Symfony\Bridge\Doctrine;
1313

14-
use Doctrine\Common\Persistence\AbstractManagerRegistry;
14+
use Doctrine\Common\Persistence\AbstractManagerRegistry as LegacyAbstractManagerRegistry;
1515
use ProxyManager\Proxy\LazyLoadingInterface;
1616
use Symfony\Component\DependencyInjection\Container;
1717

@@ -20,7 +20,7 @@
2020
*
2121
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
2222
*/
23-
abstract class ManagerRegistry extends AbstractManagerRegistry
23+
abstract class ManagerRegistry extends LegacyAbstractManagerRegistry
2424
{
2525
/**
2626
* @var Container

src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111

1212
namespace Symfony\Bridge\Doctrine\PropertyInfo;
1313

14-
use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory;
15-
use Doctrine\Common\Persistence\Mapping\MappingException;
14+
use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory as LegacyClassMetadataFactory;
15+
use Doctrine\Common\Persistence\Mapping\MappingException as LegacyMappingException;
1616
use Doctrine\DBAL\Types\Type as DBALType;
1717
use Doctrine\ORM\EntityManagerInterface;
1818
use Doctrine\ORM\Mapping\ClassMetadata;
1919
use Doctrine\ORM\Mapping\ClassMetadataInfo;
2020
use Doctrine\ORM\Mapping\MappingException as OrmMappingException;
21+
use Doctrine\Persistence\Mapping\ClassMetadataFactory;
22+
use Doctrine\Persistence\Mapping\MappingException;
2123
use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
2224
use Symfony\Component\PropertyInfo\PropertyListExtractorInterface;
2325
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
@@ -40,7 +42,7 @@ public function __construct($entityManager)
4042
{
4143
if ($entityManager instanceof EntityManagerInterface) {
4244
$this->entityManager = $entityManager;
43-
} elseif ($entityManager instanceof ClassMetadataFactory) {
45+
} elseif ($entityManager instanceof ClassMetadataFactory || $entityManager instanceof LegacyClassMetadataFactory) {
4446
@trigger_error(sprintf('Injecting an instance of "%s" in "%s" is deprecated since Symfony 4.2, inject an instance of "%s" instead.', ClassMetadataFactory::class, __CLASS__, EntityManagerInterface::class), E_USER_DEPRECATED);
4547
$this->classMetadataFactory = $entityManager;
4648
} else {

src/Symfony/Bridge/Doctrine/RegistryInterface.php

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

1212
namespace Symfony\Bridge\Doctrine;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry as ManagerRegistryInterface;
14+
use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry;
1515
use Doctrine\ORM\EntityManager;
1616

1717
/**
@@ -21,7 +21,7 @@
2121
*
2222
* @author Fabien Potencier <fabien@symfony.com>
2323
*/
24-
interface RegistryInterface extends ManagerRegistryInterface
24+
interface RegistryInterface extends LegacyManagerRegistry
2525
{
2626
/**
2727
* Gets the default entity manager name.

0 commit comments

Comments
 (0)
0