Skip to content

Commit

Permalink
bug #36749 [DI] give priority to container.hot_path over container.no…
Browse files Browse the repository at this point in the history
…_preload (nicolas-grekas)

This PR was merged into the 5.1-dev branch.

Discussion
----------

[DI] give priority to container.hot_path over container.no_preload

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Spotted by looking at a website skeleton: `ConsoleHandler` is not preloaded right now (because it listens to console events only) while it should (because it is also wired as a monolog handle and is thus on the hot path.)

Commits
-------

461041f [DI] give priority to container.hot_path over container.no_preload
  • Loading branch information
fabpot committed May 8, 2020
2 parents 4eb32cf + 461041f commit 070552e
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -851,7 +851,7 @@ protected function {$methodName}($lazyInitialization)
if ($definition->isDeprecated()) {
$deprecation = $definition->getDeprecation($id);
$code .= sprintf(" trigger_deprecation(%s, %s, %s);\n\n", $this->export($deprecation['package']), $this->export($deprecation['version']), $this->export($deprecation['message']));
} elseif (!$definition->hasTag($this->preloadTags[1])) {
} elseif ($definition->hasTag($this->hotPathTag) || !$definition->hasTag($this->preloadTags[1])) {
foreach ($this->inlinedDefinitions as $def) {
foreach ($this->getClasses($def, $id) as $class) {
$this->preload[$class] = $class;
Expand Down Expand Up @@ -1017,7 +1017,7 @@ private function addServices(array &$services = null): string
foreach ($definitions as $id => $definition) {
if (!$definition->isSynthetic()) {
$services[$id] = $this->addService($id, $definition);
} elseif (!$definition->hasTag($this->preloadTags[1])) {
} elseif ($definition->hasTag($this->hotPathTag) || !$definition->hasTag($this->preloadTags[1])) {
$services[$id] = null;

foreach ($this->getClasses($definition, $id) as $class) {
Expand Down Expand Up @@ -1046,7 +1046,7 @@ private function generateServiceFiles(array $services): iterable
ksort($definitions);
foreach ($definitions as $id => $definition) {
if ((list($file, $code) = $services[$id]) && null !== $file && ($definition->isPublic() || !$this->isTrivialInstance($definition) || isset($this->locatedIds[$id]))) {
yield $file => [$code, !$definition->hasTag($this->preloadTags[1]) && !$definition->isDeprecated() && !$definition->hasErrors()];
yield $file => [$code, $definition->hasTag($this->hotPathTag) || !$definition->hasTag($this->preloadTags[1]) && !$definition->isDeprecated() && !$definition->hasErrors()];
}
}
}
Expand Down

0 comments on commit 070552e

Please sign in to comment.