Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Filesystem] Add targetIterator for fs mirror #40689

Closed
wants to merge 15 commits into from

Conversation

danepowell
Copy link
Contributor

@danepowell danepowell commented Apr 2, 2021

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.

@carsonbot carsonbot added this to the 4.4 milestone Apr 2, 2021
@carsonbot carsonbot changed the title Fix #14068: Add targetIterator for fs mirror [Filesystem] Fix #14068: Add targetIterator for fs mirror Apr 2, 2021
@Nyholm
Copy link
Member

Nyholm commented Apr 2, 2021

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

@danepowell
Copy link
Contributor Author

Thanks, will do on Monday

@danepowell
Copy link
Contributor Author

@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.

@derrabus
Copy link
Member

derrabus commented Apr 5, 2021

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.

@Nyholm
Copy link
Member

Nyholm commented Apr 5, 2021

@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.

@danepowell
Copy link
Contributor Author

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

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I have two questions that will help me understand the PR and the issue better.

src/Symfony/Component/Filesystem/Filesystem.php Outdated Show resolved Hide resolved
src/Symfony/Component/Filesystem/Filesystem.php Outdated Show resolved Hide resolved
@danepowell
Copy link
Contributor Author

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

src/Symfony/Component/Filesystem/Filesystem.php Outdated Show resolved Hide resolved
src/Symfony/Component/Filesystem/composer.json Outdated Show resolved Hide resolved
@derrabus derrabus changed the title [Filesystem] Fix #14068: Add targetIterator for fs mirror [Filesystem] Add targetIterator for fs mirror Apr 18, 2021
@derrabus
Copy link
Member

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

@danepowell
Copy link
Contributor Author

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

@TravisCarden
Copy link
Contributor

Hey, fancy meeting you here, @danepowell! 😄

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

@derrabus
Copy link
Member

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 derrabus modified the milestones: 4.4, 5.4 Aug 10, 2021
@derrabus derrabus changed the base branch from 4.4 to 5.4 August 10, 2021 17:00
@danepowell
Copy link
Contributor Author

I rebased on 6.1 and tests are passing again.

@derrabus
Copy link
Member

derrabus commented Jan 4, 2022

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.

danepowell and others added 3 commits January 5, 2022 10:23
Co-authored-by: Alexander M. Turek <me@derrabus.de>
Co-authored-by: Alexander M. Turek <me@derrabus.de>
@danepowell
Copy link
Contributor Author

Thanks, I've addressed all feedback.

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

@stof
Copy link
Member

stof commented Jan 5, 2022

No. New features are never backported.

@danepowell
Copy link
Contributor Author

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.

@stof
Copy link
Member

stof commented Jan 5, 2022

@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.

@derrabus derrabus added Feature and removed Bug labels Apr 8, 2022
@danepowell
Copy link
Contributor Author

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

@derrabus derrabus modified the milestones: 6.1, 6.2 May 9, 2022
@fabpot
Copy link
Member

fabpot commented Jul 21, 2022

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 👎 with this PR. I would deprecate the current iterator argument instead.

@danepowell
Copy link
Contributor Author

@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
Copy link
Contributor Author

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 danepowell closed this Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Filesystem] mirror() does not work correctly with custom iterators
8 participants