8000 [FrameworkBundle] fix cache:clear command by nicolas-grekas · Pull Request #12999 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] fix cache:clear command #12999

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
Dec 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 13 additions & 5 deletions src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
} else {
// the warmup cache dir name must have the same length than the real one
// to avoid the many problems in serialized resources files
$realCacheDir = realpath($realCacheDir);
Copy link
Member

Choose a reason for hiding this comment

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

If $realCacheDir does not exists, realpath file returns false

Copy link
Member Author

Choose a reason for hiding this comment

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

The path exists because we checked it a few lines above with is_writable()

$warmupDir = substr($realCacheDir, 0, -1).'_';

if ($filesystem->exists($warmupDir)) {
Expand Down Expand Up @@ -165,12 +166,14 @@ protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = tr
*/
protected function getTempKernel(KernelInterface $parent, $namespace, $parentClass, $warmupDir)
{
$rootDir = $parent->getRootDir();
$cacheDir = var_export($warmupDir, true);
$rootDir = var_export(realpath($parent->getRootDir()), true);
$logDir = var_export(realpath($parent->getLogDir()), true);
Copy link
Member

Choose a reason for hiding this comment

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

same here

Copy link
Member Author

Choose a reason for hiding this comment

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

$parent is a booted kernel, so the paths exists, because a kernel enforces it

// the temp kernel class name must have the same length than the real one
// to avoid the many problems in serialized resources files
$class = substr($parentClass, 0, -1).'_';
// the temp kernel name must be changed too
$name = substr($parent->getName(), 0, -1).'_';
$name = var_export(substr($parent->getName(), 0, -1).'_', true);
$code = <<<EOF
<?php

Expand All @@ -180,17 +183,22 @@ class $class extends $parentClass
{
public function getCacheDir()
{
return '$warmupDir';
return $cacheDir;
}

public function getName()
{
return '$name';
return $name;
}

public function getRootDir()
{
return '$rootDir';
return $rootDir;
}

public function getLogDir()
{
return $logDir;
}

protected function buildContainer()
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/HttpKernel/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,12 +586,12 @@ protected function getKernelParameters()

return array_merge(
array(
'kernel.root_dir' => $this->rootDir,
'kernel.root_dir' => realpath($this->rootDir) ?: $this->rootDir,
'kernel.environment' => $this->environment,
'kernel.debug' => $this->debug,
'kernel.name' => $this->name,
'kernel.cache_dir' => $this->getCacheDir(),
'kernel.logs_dir' => $this->getLogDir(),
'kernel.cache_dir' => realpath($this->getCacheDir()) ?: $this->getCacheDir(),
'kernel.logs_dir' => realpath($this->getLogDir()) ?: $this->getLogDir(),
'kernel.bundles' => $bundles,
'kernel.charset' => $this->getCharset(),
'kernel.container_class' => $this->getContainerClass(),
Expand Down
0