Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ca5eea5

Browse filesBrowse files
committed
bug #10532 Fixed regression when using Symfony on filesystems without chmod support (fabpot)
This PR was merged into the 2.3 branch. Discussion ---------- Fixed regression when using Symfony on filesystems without chmod support | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #8205 | License | MIT | Doc PR | n/a Commits ------- cefb67a Fix #8205 : Deprecate file mode update when calling dumpFile
2 parents 16434b5 + cefb67a commit ca5eea5
Copy full SHA for ca5eea5

File tree

Expand file treeCollapse file tree

6 files changed

+41
-17
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+41
-17
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CompilerDebugDumpPass.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ class CompilerDebugDumpPass implements CompilerPassInterface
2020
{
2121
public function process(ContainerBuilder $container)
2222
{
23+
$filename = self::getCompilerLogFilename($container);
24+
2325
$filesystem = new Filesystem();
24-
$filesystem->dumpFile(
25-
self::getCompilerLogFilename($container),
26-
implode("\n", $container->getCompiler()->getLog()),
27-
0666 & ~umask()
28-
);
26+
$filesystem->dumpFile($filename, implode("\n", $container->getCompiler()->getLog()), null);
27+
// discard chmod failure (some filesystem may not support it)
28+
@chmod($filename, 0666 & ~umask());
2929
}
3030

3131
public static function getCompilerLogFilename(ContainerInterface $container)

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ContainerBuilderDebugDumpPass.php
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ class ContainerBuilderDebugDumpPass implements CompilerPassInterface
2828
public function process(ContainerBuilder $container)
2929
{
3030
$dumper = new XmlDumper($container);
31+
$filename = $container->getParameter('debug.container.dump');
3132
$filesystem = new Filesystem();
32-
$filesystem->dumpFile(
33-
$container->getParameter('debug.container.dump'),
34-
$dumper->dump(),
35-
0666 & ~umask()
36-
);
33+
$filesystem->dumpFile($filename, $dumper->dump(), null);
34+
// discard chmod failure (some filesystem may not support it)
35+
@chmod($filename, 0666 & ~umask());
3736
}
3837
}

‎src/Symfony/Component/Config/ConfigCache.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/ConfigCache.php
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,12 @@ public function write($content, array $metadata = null)
9595
{
9696
$mode = 0666 & ~umask();
9797
$filesystem = new Filesystem();
98-
$filesystem->dumpFile($this->file, $content, $mode);
98+
$filesystem->dumpFile($this->file, $content, null);
99+
@chmod($this->file, $mode);
99100

100101
if (null !== $metadata && true === $this->debug) {
101-
$filesystem->dumpFile($this->getMetaFile(), serialize($metadata), $mode);
102+
$filesystem->dumpFile($this->getMetaFile(), serialize($metadata), null);
103+
@chmod($this->getMetaFile(), $mode);
102104
}
103105
}
104106

‎src/Symfony/Component/Filesystem/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
2.3.12
5+
------
6+
7+
* deprecated dumpFile() file mode argument.
8+
49
2.3.0
510
-----
611

‎src/Symfony/Component/Filesystem/Filesystem.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Filesystem.php
+8-5Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,11 @@ private function toIterator($files)
444444
/**
445445
* Atomically dumps content into a file.
446446
*
447-
* @param string $filename The file to be written to.
448-
* @param string $content The data to write into the file.
449-
* @param integer $mode The file mode (octal).
450-
* @throws IOException If the file cannot be written to.
447+
* @param string $filename The file to be written to.
448+
* @param string $content The data to write into the file.
449+
* @param null|integer $mode The file mode (octal). If null, file permissions are not modified
450+
* Deprecated since version 2.3.12, to be removed in 3.0.
451+
* @throws IOException If the file cannot be written to.
451452
*/
452453
public function dumpFile($filename, $content, $mode = 0666)
453454
{
@@ -466,6 +467,8 @@ public function dumpFile($filename, $content, $mode = 0666)
466467
}
467468

468469
$this->rename($tmpFile, $filename, true);
469-
$this->chmod($filename, $mode);
470+
if (null !== $mode) {
471+
$this->chmod($filename, $mode);
472+
}
470473
}
471474
}

‎src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,21 @@ public function testDumpFile()
925925
}
926926
}
927927

928+
public function testDumpFileWithNullMode()
929+
{
930+
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'baz.txt';
931+
932+
$this->filesystem->dumpFile($filename, 'bar', null);
933+
934+
$this->assertFileExists($filename);
935+
$this->assertSame('bar', file_get_contents($filename));
936+
937+
// skip mode check on Windows
938+
if (!defined('PHP_WINDOWS_VERSION_MAJOR')) {
939+
$this->assertEquals(600, $this->getFilePermissions($filename));
940+
}
941+
}
942+
928943
public function testDumpFileOverwritesAnExistingFile()
929944
{
930945
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo.txt';

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.