Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

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

Merged
merged 1 commit into from
Nov 26, 2016

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Nov 23, 2016

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.:

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.

$container->addCompilerPass(new ValidateWorkflowsPass());
$container->addCompilerPass(new CachePoolClearerPass(), PassConfig::TYPE_AFTER_REMOVING);

if ($container->getParameter('kernel.debug')) {
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1);
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32);
Copy link
Member Author

Choose a reason for hiding this comment

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

changing to 32 to leave room for a bit of extensibility

@nicolas-grekas nicolas-grekas added this to the 3.2 milestone Nov 23, 2016
@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Nov 24, 2016

ping @stof for validation/approval please

$annotationsPool->addArgument(new Reference('monolog.logger.cache'));
} elseif ($container->has('cache.system')) {
$systemPool = $container->getDefinition('cache.system');
if ($factory === $systemPool->getFactory() && 5 === count($systemArgs = $systemPool->getArguments())) {
Copy link
Member

Choose a reason for hiding this comment

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

wouldn't it be more future-proof to use 5 <= ?

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

@nicolas-grekas
Copy link
Member Author

Ping @symfony/deciders , we need to make a decision on this one before the end of the week for 3.2 to be ready (3/3).

@nicolas-grekas
Copy link
Member Author

Last issue on the 3.2 milestone! @stof any comment?

@fabpot
Copy link
Member

fabpot commented Nov 26, 2016

Thank you @nicolas-grekas.

@fabpot fabpot merged commit f62b820 into symfony:3.2 Nov 26, 2016
fabpot added a commit that referenced this pull request 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"
@nicolas-grekas nicolas-grekas deleted the cache-system branch November 26, 2016 21:24
@fabpot fabpot mentioned this pull request Nov 27, 2016
@xabbuh
Copy link
Member

xabbuh commented Nov 27, 2016

@nicolas-grekas So does this mean that whether or not the cache.annotations service will have a logger injected will depend on which bundles I use and what they do inside their compiler passes?

@nicolas-grekas
Copy link
Member Author

cache.annotations will always have a logger, but only after the container is loaded from its dumped version. Which means always if you do offline cache warmup, and not for the very first request otherwise.

fabpot added a commit that referenced this pull request Jan 24, 2017
…fore removing passes (nicolas-grekas)

This PR was merged into the 3.2 branch.

Discussion
----------

[FrameworkBundle] Dont wire "annotations.cached_reader" before removing passes

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

This PR basically reverts #20601 and wires "annotations.cached_reader" later, so that any compiler passes needing "annotation_reader" at compile time don't get any cache - anyway, it's useless at compile time.

Commits
-------

e59f0e0 [FrameworkBundle] Dont wire "annotations.cached_reader" before removing passes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.