diff --git a/core/includes/file.inc b/core/includes/file.inc index b38cf14..d8a0e2b 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -1436,10 +1436,10 @@ function drupal_mkdir($uri, $mode = NULL, $recursive = FALSE, $context = NULL) { */ function _drupal_mkdir_call($uri, $mode, $recursive, $context) { if (is_null($context)) { - return mkdir($uri, $mode, $recursive); + return @mkdir($uri, $mode, $recursive); } else { - return mkdir($uri, $mode, $recursive, $context); + return @mkdir($uri, $mode, $recursive, $context); } } diff --git a/core/modules/system/src/Tests/File/DirectoryTest.php b/core/modules/system/src/Tests/File/DirectoryTest.php index 158be71..f4cfedf 100644 --- a/core/modules/system/src/Tests/File/DirectoryTest.php +++ b/core/modules/system/src/Tests/File/DirectoryTest.php @@ -49,6 +49,13 @@ function testFileCheckLocalDirectoryHandling() { $absolute_path = drupal_realpath($directory) . DIRECTORY_SEPARATOR . $this->randomMachineName() . DIRECTORY_SEPARATOR . $this->randomMachineName(); $this->assertTrue(drupal_mkdir($absolute_path, 0775, TRUE), 'No error reported when creating new absolute directories.', 'File'); $this->assertDirectoryPermissions($absolute_path, 0775); + + // Check that trying to create a new directory whose parent is not writable + // fails, but with no PHP error. + // Make parent directory read only. + @drupal_chmod($parent_path, 0444); + $second_child_path = $parent_path . DIRECTORY_SEPARATOR . $this->randomMachineName(); + $this->assertFalse(drupal_mkdir($second_child_path, 0775, TRUE), t('Creating child directory under a non writable parent fails.'), 'File'); } /**