Skip to content

Commit 07aac7e

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: (35 commits) fix: Improve FR validators translation [Notifier] Add push channel to notifier Fix CS [Lock] Split PdoStore into DoctrineDbalStore [Cache] Split PdoAdapter into DoctrineDbalAdapter Add swedish translation for issue #43458 [HttpClient] fix collecting debug info on destruction of CurlResponse Fix CS added missing thai translations Add missing translations for Chinese (zh_TW) [DependencyInjection] fix "url" env var processor update translation [Serializer] symfony#36594 attributes cache breaks normalization Remove untranslated translation for Afrikaans [Validator] Add missing validator polish translation [Security,Validator] Added missing Latvian translations #41053 Add the missing translations for Indonesian (id) [Validator] Add missing Lithuanian translation [Validator] Add missing Czech translation replace "ispravna" with "važeća" in translating "valid HTML/CSS" ...
2 parents a9cbda7 + 1168951 commit 07aac7e

6 files changed

+108
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CHANGELOG
1010
---
1111

1212
* Add `DoctrineOpenTransactionLoggerMiddleware` to log when a transaction has been left open
13+
* Deprecate `PdoCacheAdapterDoctrineSchemaSubscriber` and add `DoctrineDbalCacheAdapterSchemaSubscriber` instead
1314

1415
5.3
1516
---
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\Doctrine\SchemaListener;
13+
14+
use Doctrine\Common\EventSubscriber;
15+
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
16+
use Doctrine\ORM\Tools\ToolEvents;
17+
use Symfony\Component\Cache\Adapter\DoctrineSchemaConfiguratorInterface;
18+
19+
/**
20+
* Automatically adds the cache table needed for the DoctrineDbalAdapter of
21+
* the Cache component.
22+
*
23+
* @author Ryan Weaver <[email protected]>
24+
*/
25+
final class DoctrineDbalCacheAdapterSchemaSubscriber implements EventSubscriber
26+
{
27+
private $dbalAdapters;
28+
29+
/**
30+
* @param iterable<mixed, DoctrineSchemaConfiguratorInterface> $dbalAdapters
31+
*/
32+
public function __construct(iterable $dbalAdapters)
33+
{
34+
$this->dbalAdapters = $dbalAdapters;
35+
}
36+
37+
public function postGenerateSchema(GenerateSchemaEventArgs $event): void
38+
{
39+
$dbalConnection = $event->getEntityManager()->getConnection();
40+
foreach ($this->dbalAdapters as $dbalAdapter) {
41+
$dbalAdapter->configureSchema($event->getSchema(), $dbalConnection);
42+
}
43+
}
44+
45+
public function getSubscribedEvents(): array
46+
{
47+
if (!class_exists(ToolEvents::class)) {
48+
return [];
49+
}
50+
51+
return [
52+
ToolEvents::postGenerateSchema,
53+
];
54+
}
55+
}

SchemaListener/PdoCacheAdapterDoctrineSchemaSubscriber.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616
use Doctrine\ORM\Tools\ToolEvents;
1717
use Symfony\Component\Cache\Adapter\PdoAdapter;
1818

19+
trigger_deprecation('symfony/doctrine-bridge', '5.4', 'The "%s" class is deprecated, use "%s" instead.', PdoCacheAdapterDoctrineSchemaSubscriber::class, DoctrineDbalCacheAdapterSchemaSubscriber::class);
20+
1921
/**
2022
* Automatically adds the cache table needed for the PdoAdapter.
2123
*
2224
* @author Ryan Weaver <[email protected]>
25+
*
26+
* @deprecated since symfony 5.4 use DoctrineDbalCacheAdapterSchemaSubscriber
2327
*/
2428
final class PdoCacheAdapterDoctrineSchemaSubscriber implements EventSubscriber
2529
{
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\Doctrine\Tests\SchemaListener;
13+
14+
use Doctrine\DBAL\Connection;
15+
use Doctrine\DBAL\Schema\Schema;
16+
use Doctrine\ORM\EntityManagerInterface;
17+
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
18+
use PHPUnit\Framework\TestCase;
19+
use Symfony\Bridge\Doctrine\SchemaListener\DoctrineDbalCacheAdapterSchemaSubscriber;
20+
use Symfony\Component\Cache\Adapter\DoctrineSchemaConfiguratorInterface;
21+
22+
class DoctrineDbalCacheAdapterSchemaSubscriberTest extends TestCase
23+
{
24+
public function testPostGenerateSchema()
25+
{
26+
$schema = new Schema();
27+
$dbalConnection = $this->createMock(Connection::class);
28+
$entityManager = $this->createMock(EntityManagerInterface::class);
29+
$entityManager->expects($this->once())
30+
->method('getConnection')
31+
->willReturn($dbalConnection);
32+
$event = new GenerateSchemaEventArgs($entityManager, $schema);
33+
34+
$pdoAdapter = $this->createMock(DoctrineSchemaConfiguratorInterface::class);
35+
$pdoAdapter->expects($this->once())
36+
->method('configureSchema')
37+
->with($schema, $dbalConnection);
38+
39+
$subscriber = new DoctrineDbalCacheAdapterSchemaSubscriber([$pdoAdapter]);
40+
$subscriber->postGenerateSchema($event);
41+
}
42+
}

Tests/SchemaListener/PdoCacheAdapterDoctrineSchemaSubscriberTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
use Symfony\Bridge\Doctrine\SchemaListener\PdoCacheAdapterDoctrineSchemaSubscriber;
2020
use Symfony\Component\Cache\Adapter\PdoAdapter;
2121

22+
/**
23+
* @group legacy
24+
*/
2225
class PdoCacheAdapterDoctrineSchemaSubscriberTest extends TestCase
2326
{
2427
public function testPostGenerateSchema()

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@
4646
"doctrine/annotations": "^1.10.4",
4747
"doctrine/collections": "~1.0",
4848
"doctrine/data-fixtures": "^1.1",
49-
"doctrine/dbal": "^2.13|^3.0",
49+
"doctrine/dbal": "^2.13.1|^3.0",
5050
"doctrine/orm": "^2.7.3",
5151
"psr/log": "^1|^2|^3"
5252
},
5353
"conflict": {
54-
"doctrine/dbal": "<2.13",
54+
"doctrine/dbal": "<2.13.1",
5555
"doctrine/orm": "<2.7.3",
5656
"phpunit/phpunit": "<5.4.3",
57+
"symfony/cache": "<5.4",
5758
"symfony/dependency-injection": "<5.4",
5859
"symfony/form": "<5.4",
5960
"symfony/http-kernel": "<5.4",

0 commit comments

Comments
 (0)