nette / utils

🛠 Lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.
https://doc.nette.org/utils
Other
1.98k stars 147 forks source link

Finder: Fix symlink handling #295

Closed nufue closed 1 year ago

nufue commented 1 year ago

Bug Description

Finder (v2) did use isFile() or isDir() to determine type of SplFileInfo (link).

After migration to nette/utils, it uses SplFileInfo::getType() (link).

There is a slight difference between the two approaches regarding handling of symlinks - if SplFileInfo is a symlink to a file, isFile() returns true (although it is not documented - see comment), while getType() returns link (and thus fails === 'file' comparison).

This leads to change of behavior in nette/utils v4 when Finder only returns real files, not symlinks and there is no way to return to the previous behaviour.

Steps To Reproduce

  1. create a symlink to file in a directory (mkdir ./test && touch ./file.txt && cd ./test && ln -s ../file.txt)
  2. Finder::findFiles('*')->in('./test') returns empty array
dg commented 1 year ago

Thanks