Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[HttpKernel] moved the creation of logs/ and cache/ ealier to be sure…
… that directories exist when extensions want to write something into them
  • Loading branch information
fabpot committed May 13, 2011
1 parent 8dbccc7 commit faab5e4
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/Symfony/Component/HttpKernel/Kernel.php
Expand Up @@ -565,6 +565,16 @@ protected function getEnvParameters()
*/
protected function buildContainer()
{
foreach (array('cache' => $this->getCacheDir(), 'logs' => $this->getLogDir()) as $name => $dir) {
if (!is_dir($dir)) {
if (false === @mkdir($dir, 0777, true)) {
throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n", $name, dirname($dir)));
}
} elseif (!is_writable($dir)) {
throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n", $name, $dir));
}
}

$container = new ContainerBuilder(new ParameterBag($this->getKernelParameters()));
$extensions = array();
foreach ($this->bundles as $bundle) {
Expand All @@ -588,17 +598,6 @@ protected function buildContainer()
$container->merge($cont);
}

foreach (array('cache', 'logs') as $name) {
$dir = $container->getParameter(sprintf('kernel.%s_dir', $name));
if (!is_dir($dir)) {
if (false === @mkdir($dir, 0777, true)) {
throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n", $name, dirname($dir)));
}
} elseif (!is_writable($dir)) {
throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n", $name, $dir));
}
}

$container->addCompilerPass(new AddClassesToCachePass($this));
$container->compile();

Expand Down

0 comments on commit faab5e4

Please sign in to comment.