From 202bd79edb8aea27133b05f05b286ec7148cae37 Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Wed, 24 Jun 2020 07:17:04 +0200 Subject: [PATCH 1/4] After adding `symfony/proxy-manager-bridge`, table prefix went missing --- composer.json | 2 +- src/Doctrine/TablePrefix.php | 2 +- src/Doctrine/TablePrefixTrait.php | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 91da11d4..86bdf3fb 100644 --- a/composer.json +++ b/composer.json @@ -89,7 +89,6 @@ "doctrine/doctrine-migrations-bundle": "^2.1", "friends-of-behat/mink": "^1.8", "friends-of-behat/mink-browserkit-driver": "^1.4", - "friends-of-behat/symfony-extension": "^2.1", "lakion/mink-debug-extension": "^1.2", "php-http/httplug-pack": "^1.2", "php-translation/loco-adapter": "^0.11", @@ -103,6 +102,7 @@ "se/selenium-server-standalone": "^3.141", "symfony/browser-kit": "^4.4", "symfony/css-selector": "^4.4", + "symfony/proxy-manager-bridge": "^4.4", "symplify/easy-coding-standard": "^8.0", "vaimo/binary-chromedriver": "^5.0" }, diff --git a/src/Doctrine/TablePrefix.php b/src/Doctrine/TablePrefix.php index c3cf28b4..41b56c60 100644 --- a/src/Doctrine/TablePrefix.php +++ b/src/Doctrine/TablePrefix.php @@ -19,7 +19,7 @@ class TablePrefix public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void { - if ($tablePrefix = $this->getTablePrefix($eventArgs->getEntityManager())) { + if ($tablePrefix = $this->getTablePrefix()) { $classMetadata = $eventArgs->getClassMetadata(); if (! $classMetadata->isInheritanceTypeSingleTable() diff --git a/src/Doctrine/TablePrefixTrait.php b/src/Doctrine/TablePrefixTrait.php index a566e523..d4966a75 100644 --- a/src/Doctrine/TablePrefixTrait.php +++ b/src/Doctrine/TablePrefixTrait.php @@ -46,10 +46,14 @@ trait TablePrefixTrait return $this; } - protected function getTablePrefix(ObjectManager $manager) + /** + * Since we introduced `symfony/proxy-manager-bridge`, the keys in the tableprefix + * no longer match what the manager tells us it should be. For example, the + * given key was `0000000005ee10ad0000000043b453e3`, but in our reference + * table we had `0000000005ee10e90000000043b453e3`. We just return the first one, now + */ + protected function getTablePrefix(): string { - $key = spl_object_hash($manager); - - return $this->tablePrefixes[$key] ?? ''; + return current($this->tablePrefixes) ?? ''; } } From 5def9b11365f78be83c5c3ed898c39bf9f15d0ad Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Wed, 24 Jun 2020 07:35:05 +0200 Subject: [PATCH 2/4] Updates --- .gitignore | 4 ++++ composer.json | 2 +- config/bundles.php | 1 - config/services_test.yaml | 11 +++++++++-- symfony.lock | 3 +++ 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 91f24399..0fa377a4 100644 --- a/.gitignore +++ b/.gitignore @@ -88,3 +88,7 @@ appveyor.yml ###> phpunit/phpunit ### /phpunit.xml ###< phpunit/phpunit ### + +###> friends-of-behat/symfony-extension ### +/behat.yml +###< friends-of-behat/symfony-extension ### diff --git a/composer.json b/composer.json index 86bdf3fb..91da11d4 100644 --- a/composer.json +++ b/composer.json @@ -89,6 +89,7 @@ "doctrine/doctrine-migrations-bundle": "^2.1", "friends-of-behat/mink": "^1.8", "friends-of-behat/mink-browserkit-driver": "^1.4", + "friends-of-behat/symfony-extension": "^2.1", "lakion/mink-debug-extension": "^1.2", "php-http/httplug-pack": "^1.2", "php-translation/loco-adapter": "^0.11", @@ -102,7 +103,6 @@ "se/selenium-server-standalone": "^3.141", "symfony/browser-kit": "^4.4", "symfony/css-selector": "^4.4", - "symfony/proxy-manager-bridge": "^4.4", "symplify/easy-coding-standard": "^8.0", "vaimo/binary-chromedriver": "^5.0" }, diff --git a/config/bundles.php b/config/bundles.php index 2b082c4f..1d85d61d 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -23,7 +23,6 @@ return [ Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true, 'test' => true, 'local' => true], Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], Symplify\ConsoleColorDiff\ConsoleColorDiffBundle::class => ['dev' => true, 'test' => true], - Symplify\ConsoleColorDiff\ConsoleColorDiffBundle::class => ['dev' => true, 'test' => true], Translation\Bundle\TranslationBundle::class => ['all' => true], Translation\PlatformAdapter\Loco\Bridge\Symfony\TranslationAdapterLocoBundle::class => ['dev' => true, 'local' => true], ]; diff --git a/config/services_test.yaml b/config/services_test.yaml index 4e4a00e2..68b5609b 100644 --- a/config/services_test.yaml +++ b/config/services_test.yaml @@ -1,3 +1,10 @@ services: - monolog.processor.request: - synthetic: true + _defaults: + autowire: true + autoconfigure: true + + monolog.processor.request: + synthetic: true + + App\Tests\Behat\: + resource: '../tests/Behat/*' diff --git a/symfony.lock b/symfony.lock index 39118fa1..d06552a5 100644 --- a/symfony.lock +++ b/symfony.lock @@ -894,6 +894,9 @@ "symfony/property-info": { "version": "v4.4.4" }, + "symfony/proxy-manager-bridge": { + "version": "v4.4.10" + }, "symfony/routing": { "version": "4.2", "recipe": { From 2b2e22614dbd469259271ab4d4b1e92ddfcff9b5 Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Wed, 24 Jun 2020 07:36:16 +0200 Subject: [PATCH 3/4] Update .gitignore --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index 0fa377a4..80e3a389 100644 --- a/.gitignore +++ b/.gitignore @@ -89,6 +89,3 @@ appveyor.yml /phpunit.xml ###< phpunit/phpunit ### -###> friends-of-behat/symfony-extension ### -/behat.yml -###< friends-of-behat/symfony-extension ### From e20d2982cd28210a322b1053a7db578f37172ba3 Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Wed, 24 Jun 2020 08:52:33 +0200 Subject: [PATCH 4/4] Tweaking config --- .gitignore | 1 - config/services_test.yaml | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 80e3a389..91f24399 100644 --- a/.gitignore +++ b/.gitignore @@ -88,4 +88,3 @@ appveyor.yml ###> phpunit/phpunit ### /phpunit.xml ###< phpunit/phpunit ### - diff --git a/config/services_test.yaml b/config/services_test.yaml index 68b5609b..6f84f5cb 100644 --- a/config/services_test.yaml +++ b/config/services_test.yaml @@ -4,7 +4,4 @@ services: autoconfigure: true monolog.processor.request: - synthetic: true - - App\Tests\Behat\: - resource: '../tests/Behat/*' + synthetic: true \ No newline at end of file