8000 Fix unnecessary re-initialization from cache · symfony/symfony@beb307c · GitHub
[go: up one dir, main page]

Skip to content

Commit beb307c

Browse files
committed
Fix unnecessary re-initialization from cache
1 parent 8491dfd commit beb307c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Symfony/Component/Translation/Translator.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ protected function initializeCatalogue($locale)
367367
private function initializeCacheCatalogue($locale)
368368
{
369369
if (isset($this->catalogues[$locale])) {
370+
/* Catalogue already initialized. */
370371
return;
371372
}
372373

@@ -376,11 +377,15 @@ private function initializeCacheCatalogue($locale)
376377
$cache = $this->getConfigCacheFactory()->cache($cacheFile,
377378
function (ConfigCacheInterface $cache) use ($self, $locale) {
378379
$self->dumpCatalogue($locale, $cache);
379-
380-
return; // $this->catalogues[$locale] is now initialized
381380
}
382381
);
383382

383+
if (isset($this->catalogues[$locale])) {
384+
/* Catalogue has been initialized as it was written out to cache. */
385+
return;
386+
}
387+
388+
/* Read catalogue from cache. */
384389
$catalogue = include $cache->getPath();
385390

386391
/*
@@ -408,6 +413,7 @@ function (ConfigCacheInterface $cache) use ($self, $locale) {
408413
unlink($cacheFile);
409414
$this->initializeCacheCatalogue($locale);
410415
} else {
416+
/* Initialize with catalogue from cache. */
411417
$this->catalogues[$locale] = $catalogue;
412418
}
413419
}

0 commit comments

Comments
 (0)
0