diff --git a/core/includes/file.inc b/core/includes/file.inc index 6065dd4..ba09b9c 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -1275,17 +1275,14 @@ function file_get_mimetype($uri, $mapping = NULL) { */ function drupal_chmod($uri, $mode = NULL) { if (!isset($mode)) { - // Configuration system stores default modes as strings. We use octdec() so - // that the octal permission numbers can be expressed as integers or strings - // and will be converted correctly in both cases. if (is_dir($uri)) { - $mode = octdec(\Drupal::config('system.file')->get('chmod.directory')); + $mode = \Drupal::config('system.file')->get('chmod.directory'); if (!$mode) { $mode = 0775; } } else { - $mode = octdec(\Drupal::config('system.file')->get('chmod.file')); + $mode = \Drupal::config('system.file')->get('chmod.file'); if (!$mode) { $mode = 0664; } @@ -1463,7 +1460,7 @@ function drupal_mkdir($uri, $mode = NULL, $recursive = FALSE, $context = NULL) { $mode = FALSE; // During early update there's no container. if (is_object(\Drupal::getContainer())) { - $mode = octdec(\Drupal::config('system.file')->get('chmod.directory')); + $mode = \Drupal::config('system.file')->get('chmod.directory'); } if (!$mode) { $mode = 0775; diff --git a/core/modules/system/lib/Drupal/system/Tests/File/DirectoryTest.php b/core/modules/system/lib/Drupal/system/Tests/File/DirectoryTest.php index 7fd19c5..eef3373 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/DirectoryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/DirectoryTest.php @@ -89,7 +89,7 @@ function testFileCheckDirectoryHandling() { } // Test that the directory has the correct permissions. - $this->assertDirectoryPermissions($directory, octdec(\Drupal::config('system.file')->get('chmod.directory'))); + $this->assertDirectoryPermissions($directory, \Drupal::config('system.file')->get('chmod.directory')); // Remove .htaccess file to then test that it gets re-created. @drupal_unlink(file_default_scheme() . '://.htaccess'); diff --git a/core/modules/system/lib/Drupal/system/Tests/File/FileTestBase.php b/core/modules/system/lib/Drupal/system/Tests/File/FileTestBase.php index 540c19a..30973ad 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/FileTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/FileTestBase.php @@ -82,11 +82,6 @@ function assertSameFile(FileInterface $file1, FileInterface $file2) { * Optional message. */ function assertFilePermissions($filepath, $expected_mode, $message = NULL) { - // Configuration system stores default modes as strings. - if (is_string($expected_mode)) { - // Convert string to octal. - $expected_mode = octdec($expected_mode); - } // Clear out PHP's file stat cache to be sure we see the current value. clearstatcache(TRUE, $filepath); @@ -122,11 +117,6 @@ function assertFilePermissions($filepath, $expected_mode, $message = NULL) { * Optional message. */ function assertDirectoryPermissions($directory, $expected_mode, $message = NULL) { - // Configuration system stores default modes as strings. - if (is_string($expected_mode)) { - // Convert string to octal. - $expected_mode = octdec($expected_mode); - } // Clear out PHP's file stat cache to be sure we see the current value. clearstatcache(TRUE, $directory); diff --git a/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedCopyTest.php b/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedCopyTest.php index 70f1903..b9e4308 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedCopyTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedCopyTest.php @@ -34,7 +34,7 @@ function testNormal() { $this->assertEqual($new_filepath, $desired_filepath, 'Returned expected filepath.'); $this->assertTrue(file_exists($uri), 'Original file remains.'); $this->assertTrue(file_exists($new_filepath), 'New file exists.'); - $this->assertFilePermissions($new_filepath, octdec($config->get('chmod.file'))); + $this->assertFilePermissions($new_filepath, $config->get('chmod.file')); // Copying with rename. $desired_filepath = 'public://' . $this->randomName(); @@ -44,7 +44,7 @@ function testNormal() { $this->assertNotEqual($newer_filepath, $desired_filepath, 'Returned expected filepath.'); $this->assertTrue(file_exists($uri), 'Original file remains.'); $this->assertTrue(file_exists($newer_filepath), 'New file exists.'); - $this->assertFilePermissions($newer_filepath, octdec($config->get('chmod.file'))); + $this->assertFilePermissions($newer_filepath, $config->get('chmod.file')); // TODO: test copying to a directory (rather than full directory/file path) // TODO: test copying normal files using normal paths (rather than only streams) @@ -75,7 +75,7 @@ function testOverwriteSelf() { $this->assertNotEqual($new_filepath, $uri, 'Copied file has a new name.'); $this->assertTrue(file_exists($uri), 'Original file exists after copying onto itself.'); $this->assertTrue(file_exists($new_filepath), 'Copied file exists after copying onto itself.'); - $this->assertFilePermissions($new_filepath, octdec($config->get('chmod.file'))); + $this->assertFilePermissions($new_filepath, $config->get('chmod.file')); // Copy the file onto itself without renaming fails. $new_filepath = file_unmanaged_copy($uri, $uri, FILE_EXISTS_ERROR); @@ -93,6 +93,6 @@ function testOverwriteSelf() { $this->assertNotEqual($new_filepath, $uri, 'Copied file has a new name.'); $this->assertTrue(file_exists($uri), 'Original file exists after copying onto itself.'); $this->assertTrue(file_exists($new_filepath), 'Copied file exists after copying onto itself.'); - $this->assertFilePermissions($new_filepath, octdec($config->get('chmod.file'))); + $this->assertFilePermissions($new_filepath, $config->get('chmod.file')); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedMoveTest.php b/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedMoveTest.php index 1503bd1..5901a9d 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedMoveTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedMoveTest.php @@ -34,7 +34,7 @@ function testNormal() { $this->assertEqual($new_filepath, $desired_filepath, 'Returned expected filepath.'); $this->assertTrue(file_exists($new_filepath), 'File exists at the new location.'); $this->assertFalse(file_exists($uri), 'No file remains at the old location.'); - $this->assertFilePermissions($new_filepath, octdec($config->get('chmod.file'))); + $this->assertFilePermissions($new_filepath, $config->get('chmod.file')); // Moving with rename. $desired_filepath = 'public://' . $this->randomName(); @@ -45,7 +45,7 @@ function testNormal() { $this->assertNotEqual($newer_filepath, $desired_filepath, 'Returned expected filepath.'); $this->assertTrue(file_exists($newer_filepath), 'File exists at the new location.'); $this->assertFalse(file_exists($new_filepath), 'No file remains at the old location.'); - $this->assertFilePermissions($newer_filepath, octdec($config->get('chmod.file'))); + $this->assertFilePermissions($newer_filepath, $config->get('chmod.file')); // TODO: test moving to a directory (rather than full directory/file path) // TODO: test creating and moving normal files (rather than streams) diff --git a/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedSaveDataTest.php b/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedSaveDataTest.php index 043ed6c..1b03d13 100644 --- a/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedSaveDataTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedSaveDataTest.php @@ -36,6 +36,6 @@ function testFileSaveData() { $this->assertTrue($filepath, 'Unnamed file saved correctly.'); $this->assertEqual('asdf.txt', drupal_basename($filepath), 'File was named correctly.'); $this->assertEqual($contents, file_get_contents($filepath), 'Contents of the file are correct.'); - $this->assertFilePermissions($filepath, octdec(\Drupal::config('system.file')->get('chmod.file'))); + $this->assertFilePermissions($filepath, \Drupal::config('system.file')->get('chmod.file')); } }