• What are the steps required to reproduce the bug?
    call: file_check_directory($directory, FILE_CREATE_DIRECTORY, $element);
    with a directory whose parent does not exist
    eg files/foo/bar where files/ exists but not files/foo
  • What behavior were you expecting?
    i would expect it to at least try to make files/foo and then files/foo/bar
  • What happened instead?
    drupal fails silently!!

why is this a problem?
file_check_directory should not fail unless it really can't create the directory

because module developers should be able to call
-- file_check_directory($directory, FILE_CREATE_DIRECTORY, $element);

without having to
-- either call file_check_directory a million times (once for each) parent
-- OR call mkdir themselves

Comments

treksler’s picture

actually a umask might be needed to get the proper permissions with mkdir
i ended up using
if (($mode & FILE_CREATE_DIRECTORY) && @umask(0002) && @mkdir($directory, 0775, TRUE)) {

but i suppose the old umask could be preserved and set back if desired
the only question is how does (even temporarily) changing umask affect other sites on the same server

zeta ζ’s picture

Status: Active » Postponed (maintainer needs more info)

How do I call: file_check_directory($directory, FILE_CREATE_DIRECTORY, $element);? Is this for module programmers or does part of a drupal form use this to do its job?

Is this bug still present in -dev?

johannesdr’s picture

Status: Postponed (maintainer needs more info) » Needs review

This has been solved in drupal 7: #515280: file_check_directory() should create recursively
Perhaps it should be backported to Drupal 6?
So I think irstudio's patch is good, it works for me.

Status: Needs review » Needs work

The last submitted patch, file.inc__1.patch, failed testing.

johannesdr’s picture

Status: Needs work » Needs review
StatusFileSize
new810 bytes

updated patch to latest cvs version

Status: Needs review » Needs work

The last submitted patch, file-180970.patch, failed testing.

brad.bulger’s picture

Status: Needs work » Needs review

#5: file-180970.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, file-180970.patch, failed testing.

brad.bulger’s picture

this seems to be an issue with D6 testing - #961172: All D6 Core patches are failing

ygerasimov’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new1015 bytes

Thank you for patch. It really helps. Patch rerolled with git.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

Unfortunately PHP 5.0 introduced the third parameter, so we cannot just assume that is going to work on all supported PHP versions for Drupal 6. Drupal 6 should work on PHP 4.3.5 or later. In general I think it would be great to give this more eyes and testing.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.