8000 Merge branch '6.4' into 7.0 · symfony/symfony@aadd474 · GitHub
[go: up one dir, main page]

Skip to content

Commit aadd474

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: [Cache] Fix RedisTrait::createConnection for cluster [Notifier] Add docs about updating Slack messages [FrameworkBundle] Show non-bundle extensions in `debug:config` & `config:dump` list view & completion Require ORM 2.15 Deprecate using the old DBAL logger system widen return type for Monolog 3 compatibility [DoctrineBridge] Remove (wrong) PHPDoc on `ContainerAwareEventManager` [FrameworkBundle] Fix `debug:config` & `config:dump` in debug mode
2 parents 4d83313 + a38cf08 commit aadd474

22 files changed

+424
-127
lines changed

UPGRADE-6.4.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
UPGRADE FROM 6.3 to 6.4
22
=======================
33

4+
DoctrineBridge
5+
--------------
6+
7+
* Deprecate `DbalLogger`, use a middleware instead
8+
* Deprecate not constructing `DoctrineDataCollector` with an instance of `DebugDataHolder`
9+
* Deprecate `DoctrineDataCollector::addLogger()`, use a `DebugDataHolder` instead
10+
411
HttpFoundation
512
--------------
613

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
"doctrine/collections": "^1.0|^2.0",
133133
"doctrine/data-fixtures": "^1.1",
134134
"doctrine/dbal": "^2.13.1|^3.0",
135-
"doctrine/orm": "^2.12",
135+
"doctrine/orm": "^2.15",
136136
"dragonmantank/cron-expression": "^3",
137137
"egulias/email-validator": "^2.1.10|^3.1|^4",
138138
"guzzlehttp/promises": "^1.4",
@@ -164,6 +164,7 @@
164164
"async-aws/core": "<1.5",
165165
"doctrine/annotations": "<1.13.1",
166166
"doctrine/dbal": "<2.13.1",
167+
"doctrine/orm": "<2.15",
167168
"egulias/email-validator": "~3.0.0",
168169
"masterminds/html5": "<2.6",
169170
"phpdocumentor/reflection-docblock": "<5.2",

src/Symfony/Bridge/Doctrine/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
CHANGELOG
22
=========
33

4+
6.4
5+
---
6+
7+
* Deprecate `DbalLogger`, use a middleware instead
8+
* Deprecate not constructing `DoctrineDataCollector` with an instance of `DebugDataHolder`
9+
* Deprecate `DoctrineDataCollector::addLogger()`, use a `DebugDataHolder` instead
10+
411
6.3
512
---
613

src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ public function dispatchEvent($eventName, EventArgs $eventArgs = null): void
6363
}
6464
}
6565

66-
/**
67-
* @return object[][]
68-
*/
6966
public function getListeners($event = null): array
7067
{
7168
if (null === $event) {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,23 @@ public function __construct(
4343
) {
4444
$this->connections = $registry->getConnectionNames();
4545
$this->managers = $registry->getManagerNames();
46+
47+
if (null === $debugDataHolder) {
48+
trigger_deprecation('symfony/doctrine-bridge', '6.4', 'Not passing an instance of "%s" as "$debugDataHolder" to "%s()" is deprecated.', DebugDataHolder::class, __METHOD__);
49+
}
4650
}
4751

4852
/**
4953
* Adds the stack logger for a connection.
5054
*
5155
* @return void
56+
*
57+
* @deprecated since Symfony 6.4, use a DebugDataHolder instead.
5258
*/
5359
public function addLogger(string $name, DebugStack $logger)
5460
{
61+
trigger_deprecation('symfony/doctrine-bridge', '6.4', '"%s()" is deprecated. Pass an instance of "%s" to the constructor instead.', __METHOD__, DebugDataHolder::class);
62+
5563
$this->loggers[$name] = $logger;
5664
}
5765

src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@
1515
use Psr\Log\LoggerInterface;
1616
use Symfony\Component\Stopwatch\Stopwatch;
1717

18+
trigger_deprecation('symfony/doctrine-bridge', '6.4', '"%s" is deprecated, use a middleware instead.', DbalLogger::class);
19+
1820
/**
1921
* @author Fabien Potencier <fabien@symfony.com>
22+
*
23+
* @deprecated since Symfony 6.4, use a middleware instead.
2024
*/
2125
class DbalLogger implements SQLLogger
2226
{

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Doctrine\ORM\EntityManagerInterface;
1717
use Doctrine\ORM\Mapping\ClassMetadata;
1818
use Doctrine\ORM\Mapping\ClassMetadataInfo;
19-
use Doctrine\ORM\Mapping\Embedded;
2019
use Doctrine\ORM\Mapping\MappingException as OrmMappingException;
2120
use Doctrine\Persistence\Mapping\MappingException;
2221
use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
@@ -46,7 +45,7 @@ public function getProperties(string $class, array $context = []): ?array
4645

4746
$properties = array_merge($metadata->getFieldNames(), $metadata->getAssociationNames());
4847

49-
if ($metadata instanceof ClassMetadataInfo && class_exists(Embedded::class) && $metadata->embeddedClasses) {
48+
if ($metadata instanceof ClassMetadataInfo && $metadata->embeddedClasses) {
5049
$properties = array_filter($properties, fn ($property) => !str_contains($property, '.'));
5150

5251
$properties = array_merge($properties, array_keys($metadata->embeddedClasses));
@@ -122,7 +121,7 @@ public function getTypes(string $class, string $property, array $context = []):
122121
)];
123122
}
124123

125-
if ($metadata instanceof ClassMetadataInfo && class_exists(Embedded::class) && isset($metadata->embeddedClasses[$property])) {
124+
if ($metadata instanceof ClassMetadataInfo && isset($metadata->embeddedClasses[$property])) {
126125
return [new Type(Type::BUILTIN_TYPE_OBJECT, false, $metadata->embeddedClasses[$property]['class'])];
127126
}
128127

src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorWithDebugStackTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Doctrine\Persistence\ManagerRegistry;
1818
use PHPUnit\Framework\TestCase;
1919
use Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector;
20+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
2021
use Symfony\Component\HttpFoundation\Request;
2122
use Symfony\Component\HttpFoundation\Response;
2223
use Symfony\Component\VarDumper\Cloner\Data;
@@ -31,6 +32,7 @@ class_exists(\Doctrine\DBAL\Platforms\MySqlPlatform::class);
3132
class DoctrineDataCollectorWithDebugStackTest extends TestCase
3233
{
3334
use DoctrineDataCollectorTestTrait;
35+
use ExpectDeprecationTrait;
3436

3537
public function testReset()
3638
{
@@ -178,9 +180,12 @@ private function createCollector(array $queries): DoctrineDataCollector
178180
->method('getConnection')
179181
->willReturn($connection);
180182

183+
$this->expectDeprecation('Since symfony/doctrine-bridge 6.4: Not passing an instance of "Symfony\Bridge\Doctrine\Middleware\Debug\DebugDataHolder" as "$debugDataHolder" to "Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector::__construct()" is deprecated.');
181184
$collector = new DoctrineDataCollector($registry);
182185
$logger = $this->createMock(DebugStack::class);
183186
$logger->queries = $queries;
187+
188+
$this->expectDeprecation('Since symfony/doctrine-bridge 6.4: "Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector::addLogger()" is deprecated. Pass an instance of "Symfony\Bridge\Doctrine\Middleware\Debug\DebugDataHolder" to the constructor instead.');
184189
$collector->addLogger('default', $logger);
185190

186191
return $collector;

src/Symfony/Bridge/Doctrine/Tests/DoctrineTestHelper.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,14 @@ public static function createTestEntityManager(Configuration $config = null): En
4545
];
4646

4747
$config ??= self::createTestConfiguration();
48-
49-
if (!(new \ReflectionMethod(EntityManager::class, '__construct'))->isPublic()) {
50-
return EntityManager::create($params, $config);
51-
}
52-
5348
$eventManager = new EventManager();
5449

5550
return new EntityManager(DriverManager::getConnection($params, $config, $eventManager), $config, $eventManager);
5651
}
5752

5853
public static function createTestConfiguration(): Configuration
5954
{
60-
$config = class_exists(ORMSetup::class) ? ORMSetup::createConfiguration(true) : new Configuration();
55+
$config = ORMSetup::createConfiguration(true);
6156
$config->setEntityNamespaces(['SymfonyTestsDoctrine' => 'Symfony\Bridge\Doctrine\Tests\Fixtures']);
6257
$config->setAutoGenerateProxyClasses(true);
6358
$config->setProxyDir(sys_get_temp_dir());

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
1818
use Doctrine\DBAL\Types\Type as DBALType;
1919
use Doctrine\ORM\EntityManager;
20-
use Doctrine\ORM\Mapping\Column;
2120
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
2221
use Doctrine\ORM\ORMSetup;
2322
use PHPUnit\Framework\TestCase;
@@ -35,20 +34,16 @@
3534
*/
3635
class DoctrineExtractorTest extends TestCase
3736
{
38-
private function createExtractor()
37+
private function createExtractor(): DoctrineExtractor
3938
{
4039
$config = ORMSetup::createConfiguration(true);
4140
$config->setMetadataDriverImpl(new AttributeDriver([__DIR__.'/../Tests/Fixtures' => 'Symfony\Bridge\Doctrine\Tests\Fixtures'], true));
4241
if (class_exists(DefaultSchemaManagerFactory::class)) {
4342
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
4443
}
4544

46-
if (!(new \ReflectionMethod(EntityManager::class, '__construct'))->isPublic()) {
47-
$entityManager = EntityManager::create(['driver' => 'pdo_sqlite'], $config);
48-
} else {
49-
$eventManager = new EventManager();
50-
$entityManager = new EntityManager(DriverManager::getConnection(['driver' => 'pdo_sqlite'], $config, $eventManager), $config, $eventManager);
51-
}
45+
$eventManager = new EventManager();
46+
$entityManager = new EntityManager(DriverManager::getConnection(['driver' => 'pdo_sqlite'], $config, $eventManager), $config, $eventManager);
5247

5348
if (!DBALType::hasType('foo')) {
5449
DBALType::addType('foo', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineFooType');
@@ -136,19 +131,16 @@ public function testExtractWithEmbedded()
136131

137132
public function testExtractEnum()
138133
{
139-
if (!property_exists(Column::class, 'enumType')) {
140-
$this->markTestSkipped('The "enumType" requires doctrine/orm 2.11.');
141-
}
142134
$this->assertEquals([new Type(Type::BUILTIN_TYPE_OBJECT, false, EnumString::class)], $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumString', []));
143135
$this->assertEquals([new Type(Type::BUILTIN_TYPE_OBJECT, false, EnumInt::class)], $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumInt', []));
144136
$this->assertNull($this->createExtractor()->getTypes(DoctrineEnum::class, 'enumStringArray', []));
145137
$this->assertEquals([new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_OBJECT, false, EnumInt::class))], $this->createExtractor()->getTypes(DoctrineEnum::class, 'enumIntArray', []));
146138
$this->assertNull($this->createExtractor()->getTypes(DoctrineEnum::class, 'enumCustom', []));
147139
}
148140

149-
public static function typesProvider()
141+
public static function typesProvider(): array
150142
{
151-
$provider = [
143+
return [
152144
['id', [new Type(Type::BUILTIN_TYPE_INT)]],
153145
['guid', [new Type(Type::BUILTIN_TYPE_STRING)]],
154146
['bigint', [new Type(Type::BUILTIN_TYPE_STRING)]],
@@ -231,8 +223,6 @@ public static function typesProvider()
231223
)]],
232224
['json', null],
233225
];
234-
235-
return $provider;
236226
}
237227

238228
public function testGetPropertiesCatchException()

src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php

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

1212
namespace Symfony\Bridge\Doctrine\Tests\Validator;
1313

14-
use Doctrine\ORM\Mapping\Column;
1514
use PHPUnit\Framework\TestCase;
1615
use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper;
1716
use Symfony\Bridge\Doctrine\Tests\Fixtures\BaseUser;
@@ -142,10 +141,6 @@ public function testLoadClassMetadata()
142141

143142
public function testExtractEnum()
144143
{
145-
if (!property_exists(Column::class, 'enumType')) {
146-
$this->markTestSkipped('The "enumType" requires doctrine/orm 2.11.');
147-
}
148-
149144
$validator = Validation::createValidatorBuilder()
150145
->addMethodMapping('loadValidatorMetadata')
151146
->enableAnnotationMapping(true)
@@ -195,7 +190,7 @@ public function testClassValidator(bool $expected, string $classValidatorRegexp
195190
$this->assertSame($expected, $doctrineLoader->loadClassMetadata($classMetadata));
196191
}
197192

198-
public static function regexpProvider()
193+
public static function regexpProvider(): array
199194
{
200195
return [
201196
[false, null],

src/Symfony/Bridge/Doctrine/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@
4747
"doctrine/collections": "^1.0|^2.0",
4848
"doctrine/data-fixtures": "^1.1",
4949
"doctrine/dbal": "^2.13.1|^3.0",
50-
"doctrine/orm": "^2.12",
50+
"doctrine/orm": "^2.15",
5151
"psr/log": "^1|^2|^3"
5252
},
5353
"conflict": {
5454
"doctrine/annotations": "<1.13.1",
5555
"doctrine/dbal": "<2.13.1",
5656
"doctrine/lexer": "<1.1",
57-
"doctrine/orm": "<2.12",
57+
"doctrine/orm": "<2.15",
5858
"symfony/cache": "<6.4",
5959
"symfony/dependency-injection": "<6.4",
6060
"symfony/form": "<6.4",

src/Symfony/Bridge/Monolog/Handler/NotifierHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private function notify(array $records): void
7171
$this->notifier->send($notification, ...$this->notifier->getAdminRecipients());
7272
}
7373

74-
private function getHighestRecord(array $records): array
74+
private function getHighestRecord(array $records): array|LogRecord
7575
{
7676
$highestRecord = null;
7777
foreach ($records as $record) {

src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,44 @@ protected function listBundles(OutputInterface|StyleInterface $output)
5252
}
5353
}
5454

55+
protected function listNonBundleExtensions(OutputInterface|StyleInterface $output): void
56+
{
57+
$title = 'Available registered non-bundle extension aliases';
58+
$headers = ['Extension alias'];
59+
$rows = [];
60+
61+
$kernel = $this->getApplication()->getKernel();
62+
63+
$bundleExtensions = [];
64+
foreach ($kernel->getBundles() as $bundle) {
65+
if ($extension = $bundle->getContainerExtension()) {
66+
$bundleExtensions[\get_class($extension)] = true;
67+
}
68+
}
69+
70+
$extensions = $this->getContainerBuilder($kernel)->getExtensions();
71+
72+
foreach ($extensions as $alias => $extension) {
73+
if (isset($bundleExtensions[\get_class($extension)])) {
74+
continue;
75+
}
76+
$rows[] = [$alias];
77+
}
78+
79+
if (!$rows) {
80+
return;
81+
}
82+
83+
if ($output instanceof StyleInterface) {
84+
$output->title($title);
85+
$output->table($headers, $rows);
86+
} else {
87+
$output->writeln($title);
88+
$table = new Table($output);
89+
$table->setHeaders($headers)->setRows($rows)->render();
90+
}
91+
}
92+
5593
protected function findExtension(string $name): ExtensionInterface
5694
{
5795
$bundles = $this->initializeBundles();

src/Symfony/Bundle/FrameworkBundle/Command/BuildDebugContainerTrait.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,14 @@ protected function getContainerBuilder(KernelInterface $kernel): ContainerBuilde
5050
$container->getCompilerPassConfig()->setAfterRemovingPasses([]);
5151
$container->compile();
5252
} else {
53-
(new XmlFileLoader($container = new ContainerBuilder(), new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump'));
53+
$buildContainer = \Closure::bind(function () {
54+
$containerBuilder = $this->getContainerBuilder();
55+
$this->prepareContainer($containerBuilder);
56+
57+
return $containerBuilder;
58+
}, $kernel, \get_class($kernel));
59+
$container = $buildContainer();
60+
(new XmlFileLoader($container, new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump'));
5461
$locatorPass = new ServiceLocatorTagPass();
5562
$locatorPass->process($container);
5663

0 commit comments

Comments
 (0)
0