Create a directory name "0". Try to have file_scan_directory read files from that dir. It won't because "0" evalutates to false.

See example #1:
http://us2.php.net/readdir

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drewish’s picture

Version: 6.1 » 7.x-dev
Status: Needs review » Reviewed & tested by the community

need to fix this in HEAD and then backport. made false upper case but this looks good to go.

setup some test files:

amorton@minivac:~/Sites/dh/sites/default/test% mkdir 0
amorton@minivac:~/Sites/dh/sites/default/test% cd 0
amorton@minivac:~/Sites/dh/sites/default/test/0% touch foo
amorton@minivac:~/Sites/dh/sites/default/test/0% ll
total 0
-rw-r--r--  1 amorton  staff  0 Apr 15 23:38 foo

then, without the patch tried running:
print_r(file_scan_directory('sites/default/test', '.*'));

Array
(
)

after the patch it returned:

Array
(
    [sites/default/test/0/foo] => stdClass Object
        (
            [filename] => sites/default/test/0/foo
            [basename] => foo
            [name] => 
        )

)
Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD and DRUPAL-6. Let's start writing tests for these things ... thanks.

drewish’s picture

Dries, of course. if simpletest has been in core when i tested it i would have.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

cridenour’s picture

Version: 7.x-dev » 5.x-dev
Status: Closed (fixed) » Needs review
FileSize
602 bytes

Back ported for D5.

drumm’s picture

Version: 5.x-dev » 7.x-dev
Status: Needs review » Needs work

Capitalized false and committed to 5.x.

FALSE needs to be capitalized in HEAD and 6.x. Drewish mentioned this in his review.

drewish’s picture

ah, it looks like i thought i was was attaching a patch at the time.

drewish’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
986 bytes

here it is for HEAD.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Thanks. :)

webchick’s picture

Version: 7.x-dev » 6.x-dev
Status: Fixed » Reviewed & tested by the community

Oops. 6.x too.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Landed in 6.x as well. Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.