8000 [FrameworkBundle] cache annotations using DoctrineCacheBundle · Issue #20234 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] cache annotations using DoctrineCacheBundle #20234

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

Closed
IndraGunawan opened this issue Oct 18, 2016 · 5 comments
Closed

[FrameworkBundle] cache annotations using DoctrineCacheBundle #20234

IndraGunawan opened this issue Oct 18, 2016 · 5 comments

Comments

@IndraGunawan
Copy link
Contributor
# config.yml
framework:
    annotations:
        cache: doctrine_cache.providers.annotation_cache

doctrine_cache:
    providers:
        annotation_cache:
            redis:
                host: "%redis_host%"
                port: "%redis_port%"
                database: "%redis_elasticsearch_db%"
            namespace: 'annotation_cache:'

when i ran i got

  [ReflectionException]
  Class  does not exist
@zanbaldwin
Copy link
Member

Cannot reproduce this issue. The steps I took were:

  • git clone git://github.com/symfony/symfony-standard.git
  • git checkout v3.1.5
  • composer install
  • Enable DoctrineCacheBundle in AppKernel, and add the configuration you specified above (with working Redis database).
  • Visited / route which is defined by a @Route annotation.

What did you run? A specific command or custom controller?

@IndraGunawan
Copy link
Contributor Author
IndraGunawan commented Oct 18, 2016

i'm using symfony/symfony 2.7.19 and doctrine/doctrine-cache-bundle 1.3.0

the result when i run

ReflectionException in ContainerBuilder.php line 891:
Class does not exist
in ContainerBuilder.php line 891
at ReflectionClass->__construct('') in ContainerBuilder.php line 891
at ContainerBuilder->createService(object(DefinitionDecorator), 'doctrine_cache.providers.annotation_cache') in ContainerBuilder.php line 449
at ContainerBuilder->get('doctrine_cache.providers.annotation_cache', '1') in ContainerBuilder.php line 946
at ContainerBuilder->resolveServices(object(Reference)) in ContainerBuilder.php line 943
at ContainerBuilder->resolveServices(array(object(AnnotationReader), object(Reference), true)) in ContainerBuilder.php line 870
at ContainerBuilder->createService(object(Definition), 'annotations.cached_reader') in ContainerBuilder.php line 449
at ContainerBuilder->get('annotations.cached_reader') in ContainerBuilder.php line 433
at ContainerBuilder->get('annotation_reader', '1') in ContainerBuilder.php line 946
at ContainerBuilder->resolveServices(object(Reference)) in ContainerBuilder.php line 943
at ContainerBuilder->resolveServices(array(object(Reference))) in ContainerBuilder.php line 870
at ContainerBuilder->createService(object(Definition), 'vich_uploader.metadata_driver.annotation') in ContainerBuilder.php line 449
at ContainerBuilder->get('vich_uploader.metadata_driver.annotation', '1') in ContainerBuilder.php line 946
at ContainerBuilder->resolveServices(object(Reference)) in ContainerBuilder.php line 943
at ContainerBuilder->resolveServices(array(object(Reference), object(Reference), object(Reference))) in ContainerBuilder.php line 943
at ContainerBuilder->resolveServices(array(array(object(Reference), object(Reference), object(Reference)))) in ContainerBuilder.php line 870
at ContainerBuilder->createService(object(Definition), 'vich_uploader.metadata_driver.chain') in ContainerBuilder.php line 449
at ContainerBuilder->get('vich_uploader.metadata_driver.chain') in ContainerBuilder.php line 433
at ContainerBuilder->get('vich_uploader.metadata_driver', '1') in ContainerBuilder.php line 946
at ContainerBuilder->resolveServices(object(Reference)) in ContainerBuilder.php line 943
at ContainerBuilder->resolveServices(array(object(Reference), 'Metadata\ClassHierarchyMetadata', true)) in ContainerBuilder.php line 870
at ContainerBuilder->createService(object(Definition), 'vich_uploader.metadata_factory') in ContainerBuilder.php line 449
at ContainerBuilder->get('vich_uploader.metadata_factory', '1') in ContainerBuilder.php line 946
at ContainerBuilder->resolveServices(object(Reference)) in ContainerBuilder.php line 943
at ContainerBuilder->resolveServices(array(object(Reference))) in ContainerBuilder.php line 870
at ContainerBuilder->createService(object(Definition), 'vich_uploader.metadata_reader') in ContainerBuilder.php line 449
at ContainerBuilder->get('vich_uploader.metadata_reader') in RegisterPropelModelsPass.php line 30
at RegisterPropelModelsPass->process(object(ContainerBuilder)) in Compiler.php line 104
at Compiler->compile(object(ContainerBuilder)) in ContainerBuilder.php line 571
at ContainerBuilder->compile() in bootstrap.php.cache line 2669
at Kernel->initializeContainer() in bootstrap.php.cache line 2447
at Kernel->boot() in bootstrap.php.cache line 2478
at Kernel->handle(object(Request)) in app_dev.php line 30

@zanbaldwin
Copy link
Member

Sorry, still can't reproduce with Symfony 2.7.19 and DoctrineCacheBundle 1.3.0. The error is most likely coming from another part of your code.

What are you running exactly? A console command? A controller? A custom service? How are those services defined?

Can you provide any code that someone else can run the reproduce the same error you are getting? Perhaps host that in a new repository or Gist.

@IndraGunawan
Copy link
Contributor Author

sorry. i cant make the problem reproduce with fresh symfony standard edition.
i will check my code.
thanks you :D

@IndraGunawan
Copy link
Contributor Author

#20537

@IndraGunawan IndraGunawan reopened this Nov 16, 2016
fabpot added a commit that referenced this issue Nov 26, 2016
…"cache.annotations" (nicolas-grekas)

This PR was merged into the 3.2 branch.

Discussion
----------

[FrameworkBundle] Don't rely on any parent definition for "cache.annotations"

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Instead of a generic approach that failed in #20537, let's focus on the `cache.annotations` service, which is the one that needs special care because it can be required while the container is being built. See e.g.:
- #20234
- http://stackoverflow.com/questions/39625863/vichuploadbundle-inb-symfony-3-cant-load-cache-annotations-service/40626277
- schmittjoh/JMSDiExtraBundle#262

When the service is required at build time, we can't provide it a logger, because no logger service is ready at that time. Still, that doesn't prevent the service from working. The late `CachePoolClearerPass` wires the logger for later instantiations so that `cache.annotations` has a properly configured logger *for the next requests*.

Commits
-------

f62b820 [FrameworkBundle] Dont rely on any parent definition for "cache.annotations"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0