Skip to content

Commit

Permalink
revert change
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Feb 1, 2023
1 parent c39ec48 commit 5ea388d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function replace($path, $content)
$tempPath = tempnam(dirname($path), basename($path));

// Fix permissions of tempPath because `tempnam()` creates it with permissions set to 0600...
chmod($tempPath, 0666 - umask());
chmod($tempPath, 0777 - umask());

file_put_contents($tempPath, $content);

Expand Down
12 changes: 6 additions & 6 deletions tests/Filesystem/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function testFilePermissionRestoredAfterReplace()
$filesystem = new Filesystem;
$filesystem->replace($tempFile, 'Hello World');
$umaskValue = umask();
$permissionValueInDecimal = (int) base_convert('666', 8, 10);
$permissionValueInDecimal = (int) base_convert('777', 8, 10);
$actualPermission = $permissionValueInDecimal - $umaskValue;
$this->assertEquals($actualPermission, $this->getFilePermissions($tempFile));
}
Expand All @@ -124,30 +124,30 @@ public function testReplaceWhenUnixSymlinkExists()
chmod($symlinkDir, 0555);

// Test with a weird non-standard umask.
$umask = 0031;
$umask = 0131;
$originalUmask = umask($umask);

$filesystem = new Filesystem;

// Test replacing non-existent file.
$filesystem->replace($tempFile, 'Hello World');
$this->assertStringEqualsFile($tempFile, 'Hello World');
$this->assertEquals($umask, 0666 - $this->getFilePermissions($tempFile));
$this->assertEquals($umask, 0777 - $this->getFilePermissions($tempFile));

// Test replacing existing file.
$filesystem->replace($tempFile, 'Something Else');
$this->assertStringEqualsFile($tempFile, 'Something Else');
$this->assertEquals($umask, 0666 - $this->getFilePermissions($tempFile));
$this->assertEquals($umask, 0777 - $this->getFilePermissions($tempFile));

// Test replacing symlinked file.
$filesystem->replace($symlink, 'Yet Something Else Again');
$this->assertStringEqualsFile($tempFile, 'Yet Something Else Again');
$this->assertEquals($umask, 0666 - $this->getFilePermissions($tempFile));
$this->assertEquals($umask, 0777 - $this->getFilePermissions($tempFile));

umask($originalUmask);

// Reset changes to symlink_dir
chmod($symlinkDir, 0666 - $originalUmask);
chmod($symlinkDir, 0777 - $originalUmask);
}

public function testSetChmod()
Expand Down

0 comments on commit 5ea388d

Please sign in to comment.