Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix second level cache compatibility layer #1365

Merged
merged 3 commits into from
Jun 5, 2021

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Jun 2, 2021

Fixes #1364.

Our compatibility layer forgot to take into account second-level caches, which aren't set on the configuration directly but rather in a separate factory. This PR fixes this issue and adds a functional test that fetches an entity manager for each cache configuration we have: for each metadata, query, result, and second-level cache we test with the pool, psr-6 service, and doctrine/cache type. For metadata, we also test without a metadata cache configured.

@alcaeus alcaeus added the Bug label Jun 2, 2021
@alcaeus alcaeus added this to the 2.4.2 milestone Jun 2, 2021
@alcaeus alcaeus requested a review from ostrolucky June 2, 2021 09:38
@alcaeus alcaeus self-assigned this Jun 2, 2021
Comment on lines +1084 to +1086
// Disabled to prevent changing the comment below to a single-line annotation
// phpcs:disable SlevomatCodingStandard.Commenting.RequireOneLineDocComment.MultiLineDocComment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHPUnit does not seem to understand one-line annotations, so we need to disable the sniff to avoid phpcbf changing this back.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we instead disable that sniff for the whole Tests folder through the config, to avoid introducing similar issues in the future when using PHPUnit annotations on other tests ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather bug was fixed in phpunit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

long term, indeed.

Copy link
Member

@greg0ire greg0ire Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -735,7 +850,7 @@ public function testSecondLevelCache(): void
$this->assertDICDefinitionClass($myEntityRegionDef, '%doctrine.orm.second_level_cache.default_region.class%');
$this->assertDICDefinitionClass($loggerChainDef, '%doctrine.orm.second_level_cache.logger_chain.class%');
$this->assertDICDefinitionClass($loggerStatisticsDef, '%doctrine.orm.second_level_cache.logger_statistics.class%');
$this->assertDICDefinitionClass($cacheDriverDef, ArrayAdapter::class);
$this->assertDICDefinitionClass($cacheDriverDef, CacheProvider::class);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, having to change this should probably have alerted us to the bug. Oh well 🤷‍♂️

@alcaeus alcaeus requested review from nicolas-grekas, dmaicher and greg0ire and removed request for ostrolucky June 2, 2021 11:03
Copy link
Contributor

@dmaicher dmaicher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

DependencyInjection/Compiler/CacheCompatibilityPass.php Outdated Show resolved Hide resolved
DependencyInjection/Compiler/CacheCompatibilityPass.php Outdated Show resolved Hide resolved
Comment on lines +1084 to +1086
// Disabled to prevent changing the comment below to a single-line annotation
// phpcs:disable SlevomatCodingStandard.Commenting.RequireOneLineDocComment.MultiLineDocComment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather bug was fixed in phpunit

@ostrolucky ostrolucky merged commit 4202ce6 into doctrine:2.4.x Jun 5, 2021
@ostrolucky ostrolucky changed the title Test and fix cache compatibility layer Fix second level cache compatibility layer Jun 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

second level cache is broken
5 participants