Issue #2043771 by jbrown, joachim: Fixed drupal_mkdir() can't create an absolute path recursively.
parent
dc93cfdcb1
commit
420f38c5b8
|
@ -1475,8 +1475,19 @@ function drupal_mkdir($uri, $mode = NULL, $recursive = FALSE, $context = NULL) {
|
|||
$uri = str_replace('/', DIRECTORY_SEPARATOR, $uri);
|
||||
// Determine the components of the path.
|
||||
$components = explode(DIRECTORY_SEPARATOR, $uri);
|
||||
// If the filepath is absolute the first component will be empty as there
|
||||
// will be nothing before the first slash.
|
||||
if ($components[0] == '') {
|
||||
$recursive_path = DIRECTORY_SEPARATOR;
|
||||
// Get rid of the empty first component.
|
||||
array_shift($components);
|
||||
}
|
||||
else {
|
||||
$recursive_path = '';
|
||||
}
|
||||
// Don't handle the top-level directory in this loop.
|
||||
array_pop($components);
|
||||
$recursive_path = '';
|
||||
// Create each component if necessary.
|
||||
foreach ($components as $component) {
|
||||
$recursive_path .= $component;
|
||||
|
||||
|
|
|
@ -50,6 +50,11 @@ class DirectoryTest extends FileTestBase {
|
|||
|
||||
// Check that existing directory permissions were not modified.
|
||||
$this->assertDirectoryPermissions($directory, $old_mode);
|
||||
|
||||
// Check creating a directory using an absolute path.
|
||||
$absolute_path = drupal_realpath($directory) . DIRECTORY_SEPARATOR . $this->randomName() . DIRECTORY_SEPARATOR . $this->randomName();
|
||||
$this->assertTrue(drupal_mkdir($absolute_path, 0775, TRUE), 'No error reported when creating new absolute directories.', 'File');
|
||||
$this->assertDirectoryPermissions($absolute_path, 0775);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue