Skip to content

Conversation

@nufue
Copy link
Contributor

@nufue nufue commented May 16, 2023

  • bug fix / new feature? bug fix
  • BC break? possibly (changes behavior in nette/utils:4 to be compatible with behavior in nette/finder:2)
  • doc PR: not necessary

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 dg force-pushed the master branch 2 times, most recently from fc24539 to 0a94bd7 Compare July 30, 2023 12:35
@dg
Copy link
Member

dg commented Jul 30, 2023

Thanks

@dg dg force-pushed the master branch 5 times, most recently from b724dd7 to c7ec447 Compare July 30, 2023 15:42
@dg dg force-pushed the master branch 2 times, most recently from 3e4da44 to 089bddf Compare August 22, 2023 15:02
@dg dg force-pushed the master branch 2 times, most recently from fac1545 to cddcabd Compare August 29, 2023 21:58
@dg dg force-pushed the master branch 2 times, most recently from 7ccfad0 to 71017d2 Compare September 10, 2023 16:32
dg added a commit that referenced this pull request Sep 19, 2023
- getType() throws an exception when the file (no longer) exists
- there is a difference regarding handling of symlinks [#295]
@dg dg merged commit 9d324d1 into nette:master Sep 19, 2023
dg pushed a commit that referenced this pull request Sep 19, 2023
Co-authored-by: Jiri Hrazdil <jiri@hrazdil.info>
dg pushed a commit that referenced this pull request Sep 19, 2023
dg added a commit that referenced this pull request Sep 19, 2023
- getType() throws an exception when the file (no longer) exists
- there is a difference regarding handling of symlinks [#295]
dg pushed a commit that referenced this pull request Sep 19, 2023
@nufue nufue deleted the fix-finder-symlink branch December 3, 2023 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants