Skip to content

[Config] Delegate creation of ConfigCache instances to a factory. #14178

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
wants to merge 24 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix unnecessary re-initialization from cache
  • Loading branch information
mpdude committed Apr 6, 2015
commit beb307cbb1da9929bb7df3d29308f8188b79ca5a
10 changes: 8 additions & 2 deletions src/Symfony/Component/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ protected function initializeCatalogue($locale)
private function initializeCacheCatalogue($locale)
{
if (isset($this->catalogues[$locale])) {
/* Catalogue already initialized. */
return;
}

Expand All @@ -376,11 +377,15 @@ private function initializeCacheCatalogue($locale)
$cache = $this->getConfigCacheFactory()->cache($cacheFile,
function (ConfigCacheInterface $cache) use ($self, $locale) {
$self->dumpCatalogue($locale, $cache);

return; // $this->catalogues[$locale] is now initialized
}
);

if (isset($this->catalogues[$locale])) {
/* Catalogue has been initialized as it was written out to cache. */
return;
}

/* Read catalogue from cache. */
$catalogue = include $cache->getPath();

/*
Expand Down Expand Up @@ -408,6 +413,7 @@ function (ConfigCacheInterface $cache) use ($self, $locale) {
unlink($cacheFile);
$this->initializeCacheCatalogue($locale);
} else {
/* Initialize with catalogue from cache. */
$this->catalogues[$locale] = $catalogue;
}
}
Expand Down