Skip to content

[Finder] Results returns realpath instead of path specified in search #26757

Closed
@helhum

Description

@helhum
Q A
Bug report? yes
Feature request? no
BC Break report? yes
RFC? no
Symfony version 4.0.7

This commit e17a634 marks a breaking change (introduced in 4.0.7)

Setup:

Search path: /path/to/linked-folder/*/
This is a path to a symlink to /path/to/actual-folder/

Calling code:

$finder
    ->name('ext_emconf.php')
    ->followLinks()
    ->depth(0)
    ->ignoreUnreadableDirs()
    ->in($packageBasePath);

foreach ($finder as $fileInfo) {
    echo $fileInfo->getPathname() . PHP_EOL;
}

Output with symfony/finder 4.0.6:

/path/to/linked-folder/foo/composer.json

Output with symfony/finder 4.0.7:

/path/to/actual-folder/foo/composer.json

While it can be argued, that \Symfony\Component\Finder\SplFileInfo now behaves consistently with \SplFileInfo, which always returns the realpath,
it still is a breaking change from a consumer perspective, e.g. when the returned path is validated against a base path (/path/to/linked-folder/), which now fails because the symlinks are resolved by realpath.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions