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

[Bug] Run CacheSchemaSubscriberPass after CacheCollectorPass #1177

Merged
merged 1 commit into from
Jun 15, 2020

Conversation

sstok
Copy link
Contributor

@sstok sstok commented Jun 8, 2020

The CacheCollectorPass of the Cache component decorates the cache adapters with
a TracingAdapter which breaks the expectation that the provided Adapter provided to
the CacheSchemaSubscriber is a PdoAdapter with the configureSchema method.

By running the CacheSchemaSubscriberPass after the CacheCollectorPass only
the actual Adapters (not decorated one) are correctly provided.

Note: This bug only happens when debugging and the profiler is enabled.

/cc @weaverryan

@ostrolucky
Copy link
Member

ostrolucky commented Jun 8, 2020

It looks to me like your description contradicts itself:

  1. CacheCollectorPass of the Cache component decorates the cache adapters with
    a TracingAdapter

  2. By running the CacheSchemaSubscriberPass after the CacheCollectorPass only
    the actual Adapters (not decorated one) are correctly provided.

If CacheCollectorPass causes issue, how could this problem be solved by executing CacheSchemaSubscriberPass after it?

And by the way what's the actual issue from user's perspective?

@sstok
Copy link
Contributor Author

sstok commented Jun 9, 2020

The actual problem is this:

Database
--------


In PdoCacheAdapterDoctrineSchemaSubscriber.php line 40:

  Attempted to call an undefined method named "configureSchema" of class "Symfony\Component\Cache\Adapter\TraceableAdapter".


doctrine:schema:validate [--skip-mapping] [--skip-sync] [--em [EM]] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

bin/console doctrine:schema:update --force

how could this problem be solved by executing CacheSchemaSubscriberPass after it?

Because the adapter is decorated, the original definition is replaced with the TraceableAdapter, but if you execute CacheSchemaSubscriberPass after this process it will collect the original Adapter (which is still available under a different service-id). See https://github.com/symfony/symfony/blob/be8adfaf999b96c48e5543a6b72bd4f83e7f3b9a/src/Symfony/Component/Cache/DependencyInjection/CacheCollectorPass.php#L76-L77 for details.

@ostrolucky
Copy link
Member

Please also update this test case

$container->addCompilerPass(new CacheSchemaSubscriberPass(), PassConfig::TYPE_OPTIMIZE, -10);

The `CacheCollectorPass` of the Cache component decorates the cache adapters with
a `TracingAdapter` which breaks the expectation that the provided Adapter provided to
the `CacheSchemaSubscriber` is a `PdoAdapter` with the `configureSchema` method.

By running the `CacheSchemaSubscriberPass` after the `CacheCollectorPass` only
the actual Adapters (not decorated one) are correctly provided.
@sstok
Copy link
Contributor Author

sstok commented Jun 11, 2020

Please also update this test case

Done 👍

@acasademont
Copy link

Thanks @sstok I was just hit by this when updating to 2.1, hope it can be merged soon, I'm reverting back to 2.0.x meanwhile

@ostrolucky ostrolucky added this to the 2.1.1 milestone Jun 15, 2020
@ostrolucky ostrolucky merged commit 828ecf0 into doctrine:2.1.x Jun 15, 2020
@sstok sstok deleted the patch-1 branch June 15, 2020 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants