Skip to content

[Filesystem] mirror() incorrectly skips files when copying from a child directory to a parent directory #32089

@jakemalachowski

Description

@jakemalachowski

Symfony version(s) affected: 4.3+

Description
When trying to mirror a child dir into a parent dir, a check in mirror() causes all file copies to be skipped.

How to reproduce

$filesystem = new \Symfony\Component\Filesystem\Filesystem();

$dir1 = __DIR__ . '/dir1/';
$dir2 = __DIR__ . '/dir1/dir2';

mkdir($dir1);
mkdir($dir2);

touch($dir1 . '/somefile.txt');

// Fails to copy because str_pos($dir2, $dir1) === 0 on line 575 in Filesystem()
$filesystem->mirror($dir2, $dir1);

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