symfony icon indicating copy to clipboard operation
symfony copied to clipboard

[Filesystem] Add targetIterator for fs mirror

Open danepowell opened this issue 3 years ago • 22 comments

Q A
Branch? 6.1
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #14068
License MIT

The existing $iterator parameter is useless and will not behave as expected if $options['delete'] == true. There needs to be a separate iterator parameter for the target directory.

danepowell avatar Apr 02 '21 19:04 danepowell

Thank you. Could you add a test for this please? Also make sure Fabbot is happy.

Nyholm avatar Apr 02 '21 20:04 Nyholm

Thanks, will do on Monday

danepowell avatar Apr 02 '21 21:04 danepowell

@Nyholm can you help me understand why tests for this pass on my local (./phpunit src/Symfony/Component/Filesystem/) but fail in CI? It appears that the Finder component is missing in CI.

danepowell avatar Apr 05 '21 18:04 danepowell

It appears that the Finder component is missing in CI.

https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/Filesystem/composer.json

You can only use packages that appear in the component's dependencies.

derrabus avatar Apr 05 '21 18:04 derrabus

@derrabus is correct. You could fix that by adding Finder in the require-dev section.

Or even better, use the glob() to avoid the extra dependency.

Nyholm avatar Apr 05 '21 19:04 Nyholm

Thanks! This is ready for review. I don't believe the remaining failure is related to this PR.

danepowell avatar Apr 05 '21 21:04 danepowell

Okay, I've rewritten this in a way that's backwards-compatible.

danepowell avatar Apr 15 '21 20:04 danepowell

We need to decide if we want to merge this change as a bugfix. @symfony/mergers I need a second opinion for this.

derrabus avatar Apr 18 '21 19:04 derrabus

I'm happy to take any approach you decide, just let me know how you'd like to proceed.

danepowell avatar Apr 28 '21 18:04 danepowell

Hey, fancy meeting you here, @danepowell! 😄

This is biting me, too, on v5.3.4. @derrabus, can I do anything to move this forward?

TravisCarden avatar Aug 10 '21 16:08 TravisCarden

We've revised our policy regarding bugfixes recently, and I suppose we need to schedule this for 5.4 as a feature. Can you please do a rebase?

derrabus avatar Aug 10 '21 17:08 derrabus

Will this be merged?

grasmash avatar Jan 04 '22 14:01 grasmash

@danepowell looks like it needs a rebase.

grasmash avatar Jan 04 '22 14:01 grasmash

I rebased on 6.1 and tests are passing again.

danepowell avatar Jan 04 '22 21:01 danepowell

My question from April is still open: If we add a second iterator to the signature, we should have a test scenario in which both iterators are set.

derrabus avatar Jan 04 '22 22:01 derrabus

Thanks, I've addressed all feedback.

Just to confirm, this will be backported to 5.4 after being merged into 6.1?

danepowell avatar Jan 05 '22 18:01 danepowell

No. New features are never backported.

stof avatar Jan 05 '22 19:01 stof

I'd argue this is a bug, not a new feature. The expected behavior if $options['delete'] == true is to delete files in the target directory. But the actual behavior is that files are never deleted, because the origin iterator doesn't apply. That's why we jumped through hoops to make this backwards-compatible.

If we're not going to backport this, the code would be greatly simplified by breaking compatibility and getting rid of that ghost parameter.

danepowell avatar Jan 05 '22 19:01 danepowell

@danepowell breaking BC is not allowed in a minor versions. And major versions are only allowed to break BC with a migration path built for it in the previous minor. Backporting it in a patch version of 5.4 or no does not change the need for BC.

stof avatar Jan 05 '22 19:01 stof

Okay, we won't backport it. Any chance of getting this merged? Anything at all I can do to help?

danepowell avatar May 09 '22 18:05 danepowell

I'm not comfortable with this PR. I think cloning the iterator as suggested would be much better. Maybe replacing the origin directory with the target directory after cloning if part of some iterators (not sure if that's always possible). But asking the user to pass a second iterator does not seem very user-friendly.

Update: Now that I reread the code, the current iterator argument is "broken" as it does not use the originDir anyway. So, I'm :-1: with this PR. I would deprecate the current iterator argument instead.

fabpot avatar Jul 21 '22 08:07 fabpot

@fabpot the problem is that iterators contain absolute paths. If the origin and target directories are different, you must have separate iterators for each. Unless you know of some way to hack the iterator to use relative paths? That's beyond my level of comfort, but if you think it's possible and wise I can investigate.

danepowell avatar Jul 28 '22 02:07 danepowell

I can no longer reproduce the original issue here, not because it's fixed but just because so much time has elapsed and I'm no longer as familiar with these components. Between that and the obvious resistance to fixing this, I'm going to close it for now.

danepowell avatar Aug 05 '22 20:08 danepowell