Skip to content

Commit 327befe

Browse files
committed
With dumpFile() in the Filesystem class, the mode must be a param.
Clients of ConfigCache are/were using 0666 & ~umask().
1 parent 249abb3 commit 327befe

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CompilerDebugDumpPass.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ class CompilerDebugDumpPass implements CompilerPassInterface
2121
public function process(ContainerBuilder $container)
2222
{
2323
$filesystem = new Filesystem();
24-
$filesystem->dumpFile($this->getCompilerLogFilename($container), implode("\n", $container->getCompiler()->getLog()));
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)

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ContainerBuilderDebugDumpPass.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ class ContainerBuilderDebugDumpPass implements CompilerPassInterface
2828
public function process(ContainerBuilder $container)
2929
{
3030
$dumper = new XmlDumper($container);
31-
$fs = new Filesystem();
32-
$fs->dumpFile($container->getParameter('debug.container.dump'), $dumper->dump());
31+
$filesystem = new Filesystem();
32+
$filesystem->dumpFile(
33+
$container->getParameter('debug.container.dump'),
34+
$dumper->dump(),
35+
0666 & ~umask()
36+
);
3337
}
3438
}

src/Symfony/Component/Config/ConfigCache.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,12 @@ public function isFresh()
102102
*/
103103
public function write($content, array $metadata = null)
104104
{
105+
$mode = 0666 & ~umask();
105106
$filesystem = new Filesystem();
106-
$filesystem->dumpFile($this->file, $content);
107+
$filesystem->dumpFile($this->file, $content, $mode);
107108

108109
if (null !== $metadata && true === $this->debug) {
109-
$filesystem->dumpFile($this->getMetaFile(), serialize($metadata));
110+
$filesystem->dumpFile($this->getMetaFile(), serialize($metadata), $mode);
110111
}
111112
}
112113
}

src/Symfony/Component/Filesystem/Filesystem.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,12 @@ private function toIterator($files)
434434
/**
435435
* Atomically dumps content into a file.
436436
*
437-
* @param string $filename The file to be written to.
438-
* @param string $content The data to write into the file.
439-
* @throws IOException If the file cannot be written to.
437+
* @param string $filename The file to be written to.
438+
* @param string $content The data to write into the file.
439+
* @param integer $mode The file mode (octal).
440+
* @throws IOException If the file cannot be written to.
440441
*/
441-
public function dumpFile($filename, $content)
442+
public function dumpFile($filename, $content, $mode = 0666)
442443
{
443444
$dir = dirname($filename);
444445

@@ -455,6 +456,6 @@ public function dumpFile($filename, $content)
455456
}
456457

457458
$this->rename($tmpFile, $filename);
458-
$this->chmod($filename, 0666, umask());
459+
$this->chmod($filename, $mode);
459460
}
460461
}

0 commit comments

Comments
 (0)