Fix #8205 : Deprecate file mode update when calling dumpFile
This commit is contained in:
parent
16434b5611
commit
cefb67a340
@ -20,12 +20,12 @@ class CompilerDebugDumpPass implements CompilerPassInterface
|
|||||||
{
|
{
|
||||||
public function process(ContainerBuilder $container)
|
public function process(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
|
$filename = self::getCompilerLogFilename($container);
|
||||||
|
|
||||||
$filesystem = new Filesystem();
|
$filesystem = new Filesystem();
|
||||||
$filesystem->dumpFile(
|
$filesystem->dumpFile($filename, implode("\n", $container->getCompiler()->getLog()), null);
|
||||||
self::getCompilerLogFilename($container),
|
// discard chmod failure (some filesystem may not support it)
|
||||||
implode("\n", $container->getCompiler()->getLog()),
|
@chmod($filename, 0666 & ~umask());
|
||||||
0666 & ~umask()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCompilerLogFilename(ContainerInterface $container)
|
public static function getCompilerLogFilename(ContainerInterface $container)
|
||||||
|
@ -28,11 +28,10 @@ class ContainerBuilderDebugDumpPass implements CompilerPassInterface
|
|||||||
public function process(ContainerBuilder $container)
|
public function process(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
$dumper = new XmlDumper($container);
|
$dumper = new XmlDumper($container);
|
||||||
|
$filename = $container->getParameter('debug.container.dump');
|
||||||
$filesystem = new Filesystem();
|
$filesystem = new Filesystem();
|
||||||
$filesystem->dumpFile(
|
$filesystem->dumpFile($filename, $dumper->dump(), null);
|
||||||
$container->getParameter('debug.container.dump'),
|
// discard chmod failure (some filesystem may not support it)
|
||||||
$dumper->dump(),
|
@chmod($filename, 0666 & ~umask());
|
||||||
0666 & ~umask()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,10 +95,12 @@ class ConfigCache
|
|||||||
{
|
{
|
||||||
$mode = 0666 & ~umask();
|
$mode = 0666 & ~umask();
|
||||||
$filesystem = new Filesystem();
|
$filesystem = new Filesystem();
|
||||||
$filesystem->dumpFile($this->file, $content, $mode);
|
$filesystem->dumpFile($this->file, $content, null);
|
||||||
|
@chmod($this->file, $mode);
|
||||||
|
|
||||||
if (null !== $metadata && true === $this->debug) {
|
if (null !== $metadata && true === $this->debug) {
|
||||||
$filesystem->dumpFile($this->getMetaFile(), serialize($metadata), $mode);
|
$filesystem->dumpFile($this->getMetaFile(), serialize($metadata), null);
|
||||||
|
@chmod($this->getMetaFile(), $mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
2.3.12
|
||||||
|
------
|
||||||
|
|
||||||
|
* deprecated dumpFile() file mode argument.
|
||||||
|
|
||||||
2.3.0
|
2.3.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -444,10 +444,11 @@ class Filesystem
|
|||||||
/**
|
/**
|
||||||
* Atomically dumps content into a file.
|
* Atomically dumps content into a file.
|
||||||
*
|
*
|
||||||
* @param string $filename The file to be written to.
|
* @param string $filename The file to be written to.
|
||||||
* @param string $content The data to write into the file.
|
* @param string $content The data to write into the file.
|
||||||
* @param integer $mode The file mode (octal).
|
* @param null|integer $mode The file mode (octal). If null, file permissions are not modified
|
||||||
* @throws IOException If the file cannot be written to.
|
* Deprecated since version 2.3.12, to be removed in 3.0.
|
||||||
|
* @throws IOException If the file cannot be written to.
|
||||||
*/
|
*/
|
||||||
public function dumpFile($filename, $content, $mode = 0666)
|
public function dumpFile($filename, $content, $mode = 0666)
|
||||||
{
|
{
|
||||||
@ -466,6 +467,8 @@ class Filesystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->rename($tmpFile, $filename, true);
|
$this->rename($tmpFile, $filename, true);
|
||||||
$this->chmod($filename, $mode);
|
if (null !== $mode) {
|
||||||
|
$this->chmod($filename, $mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -925,6 +925,21 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDumpFileWithNullMode()
|
||||||
|
{
|
||||||
|
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'baz.txt';
|
||||||
|
|
||||||
|
$this->filesystem->dumpFile($filename, 'bar', null);
|
||||||
|
|
||||||
|
$this->assertFileExists($filename);
|
||||||
|
$this->assertSame('bar', file_get_contents($filename));
|
||||||
|
|
||||||
|
// skip mode check on Windows
|
||||||
|
if (!defined('PHP_WINDOWS_VERSION_MAJOR')) {
|
||||||
|
$this->assertEquals(600, $this->getFilePermissions($filename));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function testDumpFileOverwritesAnExistingFile()
|
public function testDumpFileOverwritesAnExistingFile()
|
||||||
{
|
{
|
||||||
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo.txt';
|
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo.txt';
|
||||||
|
Reference in New Issue
Block a user