Skip to content

Commit 6459eba

Browse files
committed
merged branch webfactory/issue-7230/picks/cache-file-utils (PR #7753)
This PR was squashed before being merged into the master branch (closes #7753). Discussion ---------- Mitigate dependency upon ConfigCache | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes (refactoring) | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | todo, issue is symfony/symfony-docs#2531 Some clients use ConfigCache only for its ability to atomically write into a file. The PR moves that code into the Filesystem component. It's a pick off #7230. __To-Do:__ - [ ] Update docs for the Filesystem component Commits ------- 3158c41 Mitigate dependency upon ConfigCache
2 parents 31bf65b + b1a2b3b commit 6459eba

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

DependencyInjection/Compiler/CompilerDebugDumpPass.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,20 @@
1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

1414
use Symfony\Component\DependencyInjection\ContainerInterface;
15-
use Symfony\Component\Config\ConfigCache;
1615
use Symfony\Component\DependencyInjection\ContainerBuilder;
1716
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17+
use Symfony\Component\Filesystem\Filesystem;
1818

1919
class CompilerDebugDumpPass implements CompilerPassInterface
2020
{
2121
public function process(ContainerBuilder $container)
2222
{
23-
$cache = new ConfigCache($this->getCompilerLogFilename($container), false);
24-
$cache->write(implode("\n", $container->getCompiler()->getLog()));
23+
$filesystem = new Filesystem();
24+
$filesystem->dumpFile(
25+
$this->getCompilerLogFilename($container),
26+
implode("\n", $container->getCompiler()->getLog()),
27+
0666 & ~umask()
28+
);
2529
}
2630

2731
public static function getCompilerLogFilename(ContainerInterface $container)

DependencyInjection/Compiler/ContainerBuilderDebugDumpPass.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\DependencyInjection\ContainerBuilder;
1515
use Symfony\Component\DependencyInjection\Dumper\XmlDumper;
1616
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17-
use Symfony\Component\Config\ConfigCache;
17+
use Symfony\Component\Filesystem\Filesystem;
1818

1919
/**
2020
* Dumps the ContainerBuilder to a cache file so that it can be used by
@@ -28,7 +28,11 @@ class ContainerBuilderDebugDumpPass implements CompilerPassInterface
2828
public function process(ContainerBuilder $container)
2929
{
3030
$dumper = new XmlDumper($container);
31-
$cache = new ConfigCache($container->getParameter('debug.container.dump'), false);
32-
$cache->write($dumper->dump());
31+
$filesystem = new Filesystem();
32+
$filesystem->dumpFile(
33+
$container->getParameter('debug.container.dump'),
34+
$dumper->dump(),
35+
0666 & ~umask()
36+
);
3337
}
3438
}

0 commit comments

Comments
 (0)